@getoatmilk/cli 0.3.4 → 0.3.5

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.
Files changed (2) hide show
  1. package/dist/oatmilk.js +3 -3
  2. package/package.json +1 -1
package/dist/oatmilk.js CHANGED
@@ -4,7 +4,7 @@ import{createRequire as iMA}from"node:module";var yMA=Object.create;var{getProto
4
4
  `)},err:(B="")=>{Q.write(`${B}
5
5
  `)},style:P_(aG(A)),errStyle:P_(aG(Q))}}async function I0(A,Q={}){if(Q.signal?.aborted)throw new n("Cancelled.",y.cancelled);let B=Q.input??process.stdin,E=Q.output??process.stderr,I=HVA({input:B,output:E,terminal:B.isTTY===!0});if(Q.secret&&B.isTTY){let J=I;J._writeToOutput=(G)=>{E.write(G.startsWith(A)?A:G.includes(`
6
6
  `)?`
7
- `:"•")}}let D;try{return await new Promise((J,G)=>{D=()=>G(new n("Cancelled.",y.cancelled)),Q.signal?.addEventListener("abort",D,{once:!0}),I.once("SIGINT",D),I.question(A,(U)=>J(U.trim()))})}finally{if(D)Q.signal?.removeEventListener("abort",D);I.close()}}async function oG(A=process.stdin){if(A.isTTY)return"";let Q=[];for await(let B of A)Q.push(Buffer.isBuffer(B)?B:Buffer.from(String(B)));return Buffer.concat(Q).toString("utf8")}var XVA;var C4=W(()=>{wQ();XVA={bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],gray:[90,39]}});var DI="0.3.4",ol;var l8=W(()=>{ol=`oatmilk-cli/0.3.4 (${process.platform}; node ${process.versions.node})`});function p8(A=process.env){return{"user-agent":ol,...A.OATMILK_PROTECTION_BYPASS?{"x-vercel-protection-bypass":A.OATMILK_PROTECTION_BYPASS}:{}}}function sl(A,Q=process.env,B=fetch){return(E,I)=>{if(new URL(E instanceof Request?E.url:String(E)).origin!==A)return B(E,I);let J=new Headers(E instanceof Request?E.headers:void 0);for(let[G,U]of new Headers(I?.headers))J.set(G,U);for(let[G,U]of Object.entries(p8(Q)))if(!J.has(G))J.set(G,U);return B(E,{...I,headers:J})}}var D6=W(()=>{l8()});async function ZVA(A){return(await w_).getRandomValues(new Uint8Array(A))}async function NVA(A){let B=Math.pow(2,8)-Math.pow(2,8)%66,E="";while(E.length<A){let I=await ZVA(A-E.length);for(let D of I)if(D<B)E+="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~"[D%66]}return E}async function zVA(A){return await NVA(A)}async function qVA(A){let Q=await(await w_).subtle.digest("SHA-256",new TextEncoder().encode(A));return btoa(String.fromCharCode(...new Uint8Array(Q))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function v_(A){if(!A)A=43;if(A<43||A>128)throw`Expected a length between 43 and 128. Received ${A}.`;let Q=await zVA(A),B=await qVA(Q);return{code_verifier:Q,code_challenge:B}}var w_;var tl=W(()=>{w_=globalThis.crypto?.webcrypto??globalThis.crypto??import("node:crypto").then((A)=>A.webcrypto)});var cQ={};pQ(cQ,{unwrapMessage:()=>J6,uint8ArrayToHex:()=>pVA,uint8ArrayToBase64url:()=>cVA,uint8ArrayToBase64:()=>Gp,toZod:()=>Ap,stringifyPrimitive:()=>HX,slugify:()=>f_,shallowClone:()=>Bp,safeExtend:()=>kVA,required:()=>fVA,randomString:()=>gVA,propertyKeyTypes:()=>u_,promiseAllObject:()=>RVA,primitiveTypes:()=>Ip,prefixIssues:()=>n8,pick:()=>wVA,partial:()=>yVA,parsedType:()=>p_,own:()=>G6,optionalKeys:()=>m_,omit:()=>vVA,objectClone:()=>LVA,numKeys:()=>TVA,nullish:()=>k_,normalizeParams:()=>KQ,mergeDefs:()=>d8,merge:()=>xVA,members:()=>d_,jsonStringifyReplacer:()=>C6,joinValues:()=>YX,issue:()=>U6,isPlainObject:()=>BJ,isObject:()=>rG,installLazyProp:()=>aVA,hide:()=>i_,hexToUint8Array:()=>lVA,getSizableOrigin:()=>Dp,getParsedType:()=>PVA,getLengthableOrigin:()=>PY,getEnumValues:()=>RY,getElementAtPath:()=>jVA,floatSafeRemainder:()=>x_,finalizeIssue:()=>M1,extend:()=>bVA,explicitlyAborted:()=>l_,escapeRegex:()=>i8,esc:()=>y_,defineLazyInternal:()=>TB,defineLazy:()=>Qp,createTransparentProxy:()=>SVA,constantCatch:()=>Up,codePointLength:()=>TY,cloneDef:()=>WVA,clone:()=>y4,cleanRegex:()=>gY,cleanEnum:()=>uVA,captureStackTrace:()=>KX,cached:()=>$6,base64urlToUint8Array:()=>mVA,base64ToUint8Array:()=>Jp,attachSchema:()=>XX,assignProp:()=>JI,assertNotEqual:()=>MVA,assertNever:()=>_VA,assertIs:()=>VVA,assertEqual:()=>FVA,assert:()=>OVA,allowsEval:()=>h_,aborted:()=>IJ,NUMBER_FORMAT_RANGES:()=>c_,Class:()=>Cp,CONSTANT_CATCH:()=>$p,BIGINT_FORMAT_RANGES:()=>Ep});function FVA(A){return A}function MVA(A){return A}function Ap(){return(A)=>A}function VVA(A){}function _VA(A){throw Error("Unexpected value in exhaustive check")}function OVA(A){}function RY(A){let Q=Object.values(A).filter((E)=>typeof E==="number");return Object.entries(A).filter(([E,I])=>Q.indexOf(+E)===-1).map(([E,I])=>I)}function YX(A,Q="|"){return A.map((B)=>HX(B)).join(Q)}function C6(A,Q){if(typeof Q==="bigint")return Q.toString();return Q}function $6(A){return{get value(){{let B=A();return Object.defineProperty(this,"value",{value:B}),B}throw Error("cached value already set")}}}function k_(A){return A===null||A===void 0}function gY(A){let Q=A.startsWith("^")?1:0,B=A.endsWith("$")?A.length-1:A.length;return A.slice(Q,B)}function x_(A,Q){let B=A/Q,E=Math.round(B),I=4*Number.EPSILON*Math.max(Math.abs(B),1);if(Math.abs(B-E)<I)return 0;return B-E}function Qp(A,Q,B){let E=void 0;Object.defineProperty(A,Q,{get(){if(E===el)return;if(E===void 0)E=el,E=B();return E},set(I){Object.defineProperty(A,Q,{value:I})},configurable:!0})}function LVA(A){return Object.create(Object.getPrototypeOf(A),Object.getOwnPropertyDescriptors(A))}function JI(A,Q,B){Object.defineProperty(A,Q,{value:B,writable:!0,enumerable:!0,configurable:!0})}function d8(...A){let Q={};for(let B of A){let E=Object.getOwnPropertyDescriptors(B);Object.assign(Q,E)}return Object.defineProperties({},Q)}function WVA(A){return d8(A._zod.def)}function jVA(A,Q){if(!Q)return A;return Q.reduce((B,E)=>B?.[E],A)}function RVA(A){let Q=Object.keys(A),B=Q.map((E)=>A[E]);return Promise.all(B).then((E)=>{let I={};for(let D=0;D<Q.length;D++)I[Q[D]]=E[D];return I})}function gVA(A=10){let B="";for(let E=0;E<A;E++)B+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return B}function y_(A){return JSON.stringify(A)}function f_(A){return A.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function rG(A){return typeof A==="object"&&A!==null&&!Array.isArray(A)}function BJ(A){if(rG(A)===!1)return!1;let Q=A.constructor;if(Q===void 0)return!0;if(typeof Q!=="function")return!0;let B=Q.prototype;if(rG(B)===!1)return!1;if(Object.prototype.hasOwnProperty.call(B,"isPrototypeOf")===!1)return!1;return!0}function Bp(A){if(BJ(A))return{...A};if(Array.isArray(A))return[...A];if(A instanceof Map)return new Map(A);if(A instanceof Set)return new Set(A);return A}function TVA(A){let Q=0;for(let B in A)if(Object.prototype.hasOwnProperty.call(A,B))Q++;return Q}function i8(A){return A.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function y4(A,Q,B){let E=new A._zod.constr(Q??A._zod.def);if(!Q||B?.parent)E._zod.parent=A;return E}function KQ(A){let Q=A;if(!Q)return{};if(typeof Q==="string")return{error:()=>Q};if(Q?.message!==void 0){if(Q?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");Q.error=Q.message}if(delete Q.message,typeof Q.error==="string")return{...Q,error:()=>Q.error};return Q}function SVA(A){let Q;return new Proxy({},{get(B,E,I){return Q??(Q=A()),Reflect.get(Q,E,I)},set(B,E,I,D){return Q??(Q=A()),Reflect.set(Q,E,I,D)},has(B,E){return Q??(Q=A()),Reflect.has(Q,E)},deleteProperty(B,E){return Q??(Q=A()),Reflect.deleteProperty(Q,E)},ownKeys(B){return Q??(Q=A()),Reflect.ownKeys(Q)},getOwnPropertyDescriptor(B,E){return Q??(Q=A()),Reflect.getOwnPropertyDescriptor(Q,E)},defineProperty(B,E,I){return Q??(Q=A()),Reflect.defineProperty(Q,E,I)}})}function HX(A){if(typeof A==="bigint")return A.toString()+"n";if(typeof A==="string")return`"${A}"`;return`${A}`}function m_(A){return Object.keys(A).filter((Q)=>{return A[Q]._zod.optin!==void 0&&A[Q]._zod.optout==="optional"})}function wVA(A,Q){let B=A._zod.def,E=B.checks;if(E&&E.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let D=d8(A._zod.def,{get shape(){let J={};for(let G of Reflect.ownKeys(Q)){if(!Object.prototype.hasOwnProperty.call(B.shape,G))throw Error(`Unrecognized key: "${String(G)}"`);if(!Q[G])continue;JI(J,G,B.shape[G])}return JI(this,"shape",J),J},checks:[]});return y4(A,D)}function vVA(A,Q){let B=A._zod.def,E=B.checks;if(E&&E.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let D=d8(A._zod.def,{get shape(){let J={...A._zod.def.shape};for(let G of Reflect.ownKeys(Q)){if(!Object.prototype.hasOwnProperty.call(B.shape,G))throw Error(`Unrecognized key: "${String(G)}"`);if(!Q[G])continue;delete J[G]}return JI(this,"shape",J),J},checks:[]});return y4(A,D)}function bVA(A,Q){if(!BJ(Q))throw Error("Invalid input to extend: expected a plain object");let B=A._zod.def.checks;if(B&&B.length>0){let D=A._zod.def.shape;for(let J of Reflect.ownKeys(Q))if(Object.getOwnPropertyDescriptor(D,J)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let I=d8(A._zod.def,{get shape(){let D={...A._zod.def.shape,...Q};return JI(this,"shape",D),D}});return y4(A,I)}function kVA(A,Q){if(!BJ(Q))throw Error("Invalid input to safeExtend: expected a plain object");let B=d8(A._zod.def,{get shape(){let E={...A._zod.def.shape,...Q};return JI(this,"shape",E),E}});return y4(A,B)}function xVA(A,Q){if(!Q?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(A._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let B=d8(A._zod.def,{get shape(){let E={...A._zod.def.shape,...Q._zod.def.shape};return JI(this,"shape",E),E},get catchall(){return Q._zod.def.catchall},checks:Q._zod.def.checks??[]});return y4(A,B)}function yVA(A,Q,B,E="partial"){let D=Q._zod.def.checks;if(D&&D.length>0)throw Error(`.${E}() cannot be used on object schemas containing refinements`);let G=d8(Q._zod.def,{get shape(){let U=Q._zod.def.shape,Y={...U};if(B)for(let H of Reflect.ownKeys(B)){if(!Object.prototype.hasOwnProperty.call(U,H))throw Error(`Unrecognized key: "${String(H)}"`);if(!B[H])continue;Y[H]=A?new A({type:"optional",innerType:U[H]}):U[H]}else for(let H of Reflect.ownKeys(U))Y[H]=A?new A({type:"optional",innerType:U[H]}):U[H];return JI(this,"shape",Y),Y},checks:[]});return y4(Q,G)}function fVA(A,Q,B){let E=d8(Q._zod.def,{get shape(){let I=Q._zod.def.shape,D={...I};if(B)for(let J of Reflect.ownKeys(B)){if(!Object.prototype.hasOwnProperty.call(D,J))throw Error(`Unrecognized key: "${String(J)}"`);if(!B[J])continue;D[J]=new A({type:"nonoptional",innerType:I[J]})}else for(let J of Reflect.ownKeys(I))D[J]=new A({type:"nonoptional",innerType:I[J]});return JI(this,"shape",D),D}});return y4(Q,E)}function IJ(A,Q=0){if(A.aborted===!0)return!0;for(let B=Q;B<A.issues.length;B++)if(A.issues[B]?.continue!==!0)return!0;return!1}function l_(A,Q=0){if(A.aborted===!0)return!0;for(let B=Q;B<A.issues.length;B++)if(A.issues[B]?.continue===!1)return!0;return!1}function n8(A,Q){return Q.map((B)=>{var E;return(E=B).path??(E.path=[]),B.path.unshift(A),B})}function J6(A){return typeof A==="string"?A:A?.message}function XX(A,Q,B){var E;for(let I=Q;I<A.length;I++)(E=A[I]).schema??(E.schema=B)}function M1(A,Q,B){var E;let I=A.inst?._zod?.traits;if(I?.has("$ZodType"))if(I.has("$ZodCheck"))(E=A).schema??(E.schema=A.inst);else A.schema=A.inst;let D=A.schema!==A.inst?A.schema?._zod.def?.error:void 0,J=A.message?A.message:J6(A.inst?._zod.def?.error?.(A))??J6(D?.(A))??J6(Q?.error?.(A))??J6(B.customError?.(A))??J6(B.localeError?.(A))??"Invalid input",{inst:G,schema:U,continue:Y,input:H,...X}=A;if(X.path??(X.path=[]),X.message=J,Q?.reportInput)X.input=H;return X}function Dp(A){if(A instanceof Set)return"set";if(A instanceof Map)return"map";if(A instanceof File)return"file";return"unknown"}function TY(A){let Q=A.length;if(!hVA.test(A))return Q;let B=Q;for(let E=0;E<Q-1;E++)if((A.charCodeAt(E)&64512)===55296&&(A.charCodeAt(E+1)&64512)===56320)B--,E++;return B}function PY(A){if(Array.isArray(A))return"array";if(typeof A==="string")return"string";return"unknown"}function p_(A){let Q=typeof A;switch(Q){case"number":return Number.isNaN(A)?"nan":"number";case"object":{if(A===null)return"null";if(Array.isArray(A))return"array";let B=A;if(B&&Object.getPrototypeOf(B)!==Object.prototype&&"constructor"in B&&B.constructor)return B.constructor.name}}return Q}function U6(...A){let[Q,B,E]=A;if(typeof Q==="string")return{message:Q,code:"custom",input:B,inst:E};return{...Q}}function uVA(A){return Object.entries(A).filter(([Q,B])=>{return Number.isNaN(Number.parseInt(Q,10))}).map((Q)=>Q[1])}function Jp(A){let Q=atob(A),B=new Uint8Array(Q.length);for(let E=0;E<Q.length;E++)B[E]=Q.charCodeAt(E);return B}function Gp(A){let Q="";for(let B=0;B<A.length;B++)Q+=String.fromCharCode(A[B]);return btoa(Q)}function mVA(A){let Q=A.replace(/-/g,"+").replace(/_/g,"/"),B="=".repeat((4-Q.length%4)%4);return Jp(Q+B)}function cVA(A){return Gp(A).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function lVA(A){let Q=A.replace(/^0x/,"");if(Q.length%2!==0)throw Error("Invalid hex string length");let B=new Uint8Array(Q.length/2);for(let E=0;E<Q.length;E+=2)B[E/2]=Number.parseInt(Q.slice(E,E+2),16);return B}function pVA(A){return Array.from(A).map((Q)=>Q.toString(16).padStart(2,"0")).join("")}class Cp{constructor(...A){}}function d_(A,Q){for(let B in Q){let E=Object.getOwnPropertyDescriptor(Q,B);if(E.get)Object.defineProperty(A,B,{...E,enumerable:!1});else dVA(A,B,E.value)}}function G6(A,Q,B,E=!0){return Object.defineProperty(A,Q,{configurable:!0,writable:!0,enumerable:E,value:B}),B}function i_(A,Q,B){return G6(A,Q,B,!1)}function dVA(A,Q,B){Object.defineProperty(A,Q,{configurable:!0,get(){return this==null?B:G6(this,Q,B.bind(this))},set(E){G6(this,Q,E)}})}function iVA(A,Q){let B=Object.getPrototypeOf(A);return Q in B?void 0:B}function TB(A,Q,B){let E=Object.getPrototypeOf(A._zod);if(Q in E&&b_!==A._zod){b_=void 0;return}b_=A._zod,Object.defineProperty(E,Q,{configurable:!0,get(){Object.defineProperty(this,Q,nVA);let I=QJ;QJ=!1;try{let D=B(this);if(QJ)delete this[Q];else Object.defineProperty(this,Q,{configurable:!0,writable:!0,value:D});return QJ=QJ||I,D}catch(D){throw delete this[Q],QJ=QJ||I,D}},set(I){Object.defineProperty(this,Q,{configurable:!0,writable:!0,value:I})}})}function aVA(A,Q,B,E){let I=iVA(A,Q);if(!I)return;Object.defineProperty(I,Q,{configurable:!0,get(){let D={configurable:!0,writable:!0,enumerable:E,value:void 0};return Object.defineProperty(this,Q,D),D.value=B(this),Object.defineProperty(this,Q,D),D.value},set(D){Object.defineProperty(this,Q,{configurable:!0,writable:!0,enumerable:E,value:D})}})}function Up(A){let Q=()=>A;return Q[$p]=!0,Q}var el,KX,h_,PVA=(A)=>{let Q=typeof A;switch(Q){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(A)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(A))return"array";if(A===null)return"null";if(A.then&&typeof A.then==="function"&&A.catch&&typeof A.catch==="function")return"promise";if(typeof Map<"u"&&A instanceof Map)return"map";if(typeof Set<"u"&&A instanceof Set)return"set";if(typeof Date<"u"&&A instanceof Date)return"date";if(typeof File<"u"&&A instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${Q}`)}},u_,Ip,c_,Ep,hVA,b_,QJ=!1,nVA,$p="~constantCatch";var $4=W(()=>{sG();el=Symbol("evaluating");KX="captureStackTrace"in Error?Error.captureStackTrace:(...A)=>{};h_=$6(()=>{if(RE.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(A){return!1}});u_=new Set(["string","number","symbol"]),Ip=new Set(["string","number","bigint","boolean","symbol","undefined"]);c_=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Ep={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};hVA=/[\uD800-\uDBFF]/;nVA={configurable:!0,get(){QJ=!0;return}}});function oVA(A){let Q=Kp;if(Q){let B=Q.stackTraceLimit;if(typeof B==="number"){try{Q.stackTraceLimit=0}catch{return Kp=null,new A}try{return new A}finally{Q.stackTraceLimit=B}}}return new A}function JA(A,Q,B,E){let I={};function D(N){this.def=N,this.constr=X,this.traits=new Set}D.prototype=I;let J=B,G=J&&new WeakSet;function U(N,z){if(!N._zod){n_.value=new D(z);try{Object.defineProperty(N,"_zod",n_)}finally{n_.value=void 0}}if(N._zod.traits.has(A))return;if(N._zod.traits.add(A),Q(N,z),G){let V=Object.getPrototypeOf(N),O=N._zod.constr.prototype,j=V;while(j&&j!==O)j=Object.getPrototypeOf(j);let b=j??V;if(!G.has(b))G.add(b),d_(b,J)}let F=X.prototype;for(let V in F){if(!Object.prototype.hasOwnProperty.call(F,V))continue;if(!(V in N))N[V]=F[V].bind(N)}}let Y=E?.Parent??Object;class H extends Y{}Object.defineProperty(H,"name",{value:A});function X(N){let z=E?.Parent?oVA(H):this;U(z,N);let F=z._zod.deferred;if(F){for(let O of F)O();z._zod.deferred=void 0}let V=globalThis.__zod_globalConfig?.postProcessor;if(V)V(z);return z}return Object.defineProperty(X,"init",{value:U}),Object.defineProperty(X,Symbol.hasInstance,{value:(N)=>{if(E?.Parent&&N instanceof E.Parent)return!0;return N?._zod?.traits?.has(A)}}),Object.defineProperty(X,"name",{value:A}),X}function gE(A){if(A)Object.assign(RE,A);return RE}var Yp,a_,n_,Kp,a8,SY,RE;var sG=W(()=>{$4();a_=Object.freeze({status:"aborted"}),n_={value:void 0,enumerable:!1},Kp="captureStackTrace"in Error?Error:null;a8=class a8 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};SY=class SY extends Error{constructor(A){super(`Encountered unidirectional transform during encode: ${A}`);this.name="ZodEncodeError"}};(Yp=globalThis).__zod_globalConfig??(Yp.__zod_globalConfig={});RE=globalThis.__zod_globalConfig});function rVA(){let A=this._zod;return A.message??(A.message=JSON.stringify(A.def,C6,2)),A.message}function sVA(A){this._zod.message=A}function eVA(A,Q,B){if(!Object.prototype.hasOwnProperty.call(A,Q))if(Q==="__proto__")Object.defineProperty(A,Q,{value:B(),writable:!0,enumerable:!0,configurable:!0});else A[Q]=B();return A[Q]}function e_(A,Q=(B)=>B.message){let B={},E=[];for(let I of A.issues)if(I.path.length>0)eVA(B,I.path[0],()=>[]).push(Q(I));else E.push(Q(I));return{formErrors:E,fieldErrors:B}}function AO(A,Q=(B)=>B.message){let B={_errors:[]},E=(I,D=[])=>{for(let J of I.issues)if(J.code==="invalid_union"&&J.errors.length)J.errors.map((G)=>E({issues:G},[...D,...J.path]));else if(J.code==="invalid_key")E({issues:J.issues},[...D,...J.path]);else if(J.code==="invalid_element")E({issues:J.issues},[...D,...J.path]);else{let G=[...D,...J.path];if(G.length===0)B._errors.push(Q(J));else{let U=B,Y=0;while(Y<G.length){let H=G[Y],X=Y===G.length-1;if(H==="_errors"){if(X)U._errors.push(Q(J));Y++;continue}if(!Object.prototype.hasOwnProperty.call(U,H))Object.defineProperty(U,H,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let N=U[H];if(X)N._errors.push(Q(J));U=N,Y++}}}};return E(A),B}var tVA,r_,s_,Hp,Xp=(A,Q)=>{A.name="$ZodError",r_.value=A._zod,Object.defineProperty(A,"_zod",r_),s_.value=Q,Object.defineProperty(A,"issues",s_),r_.value=void 0,s_.value=void 0,Object.defineProperty(A,"message",tVA);let B=Object.getPrototypeOf(A);if(!Hp.has(B))Hp.add(B),Object.defineProperty(B,"toString",{configurable:!0,enumerable:!1,get(){let E=()=>this.message;return Object.defineProperty(this,"toString",{value:E,configurable:!0,writable:!0}),E},set(E){Object.defineProperty(this,"toString",{value:E,configurable:!0,writable:!0})}})},ZX,t_;var QO=W(()=>{sG();$4();tVA={get:rVA,set:sVA,enumerable:!0,configurable:!0},r_={value:void 0,enumerable:!1},s_={value:void 0,enumerable:!1},Hp=new WeakSet([Object.prototype,Error.prototype]),ZX=JA("$ZodError",Xp),t_=JA("$ZodError",Xp,void 0,{Parent:Error})});function NX(A,Q){return{callee:Q?.callee??A,Err:Q?.Err}}var zX=(A)=>{let Q=(B,E,I,D)=>{let J=I?{...I,async:!1}:{async:!1},G=B._zod.run({value:E,issues:[]},J);if(G instanceof Promise)throw new a8;if(G.issues.length){let U=new(D?.Err??A)(G.issues.map((Y)=>M1(Y,J,gE())));throw KX(U,D?.callee??Q),U}return G.value};return Q},qX=(A)=>{let Q=async(B,E,I,D)=>{let J=I?{...I,async:!0}:{async:!0},G=B._zod.run({value:E,issues:[]},J);if(G instanceof Promise)G=await G;if(G.issues.length){let U=new(D?.Err??A)(G.issues.map((Y)=>M1(Y,J,gE())));throw KX(U,D?.callee??Q),U}return G.value};return Q},wY=(A)=>(Q,B,E)=>{let I=E?{...E,async:!1}:{async:!1},D=Q._zod.run({value:B,issues:[]},I);if(D instanceof Promise)throw new a8;return D.issues.length?{success:!1,error:new(A??ZX)(D.issues.map((J)=>M1(J,I,gE())))}:{success:!0,data:D.value}},vY,bY=(A)=>async(Q,B,E)=>{let I=E?{...E,async:!0}:{async:!0},D=Q._zod.run({value:B,issues:[]},I);if(D instanceof Promise)D=await D;return D.issues.length?{success:!1,error:new A(D.issues.map((J)=>M1(J,I,gE())))}:{success:!0,data:D.value}},FX,Zp=(A)=>{let Q=zX(A),B=(E,I,D,J)=>{let G=D?{...D,direction:"backward"}:{direction:"backward"};return Q(E,I,G,NX(B,J))};return B},Np=(A)=>{let Q=zX(A),B=(E,I,D,J)=>{return Q(E,I,D,NX(B,J))};return B},zp=(A)=>{let Q=qX(A),B=async(E,I,D,J)=>{let G=D?{...D,direction:"backward"}:{direction:"backward"};return await Q(E,I,G,NX(B,J))};return B},qp=(A)=>{let Q=qX(A),B=async(E,I,D,J)=>{return await Q(E,I,D,NX(B,J))};return B},Fp=(A)=>(Q,B,E)=>{let I=E?{...E,direction:"backward"}:{direction:"backward"};return wY(A)(Q,B,I)},Mp=(A)=>(Q,B,E)=>{return wY(A)(Q,B,E)},Vp=(A)=>async(Q,B,E)=>{let I=E?{...E,direction:"backward"}:{direction:"backward"};return bY(A)(Q,B,I)},_p=(A)=>async(Q,B,E)=>{return bY(A)(Q,B,E)};var BO=W(()=>{sG();QO();$4();vY=wY(t_),FX=bY(t_)});function Tp(A){return new RegExp(`^[a-zA-Z0-9_-]{${A}}$`)}function vp(){return new RegExp(Q_A,"u")}function B_A(A){return new RegExp(`^${A}$`)}function IO(A){return typeof A.precision==="number"?A.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":A.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${A.precision}}`:A.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function lp(A){return new RegExp(`^${IO(A)}$`)}function pp(A){let Q=["Z"];if(A.offset)Q.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let B=`${IO({precision:A.precision,seconds:!0})}(?:${Q.join("|")})`,E=A.local?`${B}|${IO({precision:A.precision})}`:B;return new RegExp(`^${mp}T(?:${E})$`)}var Op,Lp,Wp,jp,Rp,gp,Pp,Sp,EO=(A)=>{if(!A)return/^([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|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${A}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},wp,Q_A="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$",bp,kp,xp,yp,fp,DO,hp,up,mp="(?:(?:\\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])))",cp,dp=(A)=>{let Q=A?`[\\s\\S]{${A?.minimum??0},${A?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${Q}$`)},ip,MX,Y6,np,ap,op,rp;var kY=W(()=>{Op=/^[cC][0-9a-z]{6,}$/,Lp=/^[0-9a-z]+$/,Wp=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,jp=/^[0-9a-vA-V]{20}$/,Rp=/^[A-Za-z0-9]{27}$/,gp=/^[a-zA-Z0-9_-]{21}$/;Pp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Sp=/^([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})$/,wp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;bp=/^(?:(?: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])$/,kp=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,xp=/^((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])$/,yp=/^(([0-9a-fA-F]{1,4}:){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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,fp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,DO=/^[A-Za-z0-9_-]*$/,hp=/^https?$/,up=/^\+[1-9]\d{6,14}$/;cp=B_A(mp);ip=/^-?\d+n?$/,MX=/^-?\d+$/,Y6=/^-?\d+(?:\.\d+)?$/,np=/^(?:true|false)$/i,ap=/^null$/i,op=/^[^A-Z]*$/,rp=/^[^a-z]*$/});var PI,JO=(A)=>{let Q=A.value;return!k_(Q)&&Q.length!==void 0},VX,GO,CO,sp,tp,ep,Ad,Qd,xY,Bd,Id,Ed,Dd,Jd,Gd,Cd;var _X=W(()=>{sG();kY();$4();PI=JA("$ZodCheck",(A,Q)=>{var B;A._zod??(A._zod={}),A._zod.def=Q,(B=A._zod).onattach??(B.onattach=[])}),VX={number:"number",bigint:"bigint",object:"date"},GO=JA("$ZodCheckLessThan",(A,Q)=>{PI.init(A,Q);let B=VX[typeof Q.value];A._zod.onattach.push((E)=>{let I=E._zod.bag,D=(Q.inclusive?I.maximum:I.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(Q.value<D)if(Q.inclusive)I.maximum=Q.value;else I.exclusiveMaximum=Q.value}),A._zod.check=(E)=>{if(Q.inclusive?E.value<=Q.value:E.value<Q.value)return;E.issues.push({origin:VX[typeof E.value]??B,code:"too_big",maximum:typeof Q.value==="object"?Q.value.getTime():Q.value,input:E.value,inclusive:Q.inclusive,inst:A,continue:!Q.abort})}}),CO=JA("$ZodCheckGreaterThan",(A,Q)=>{PI.init(A,Q);let B=VX[typeof Q.value];A._zod.onattach.push((E)=>{let I=E._zod.bag,D=(Q.inclusive?I.minimum:I.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(Q.value>D)if(Q.inclusive)I.minimum=Q.value;else I.exclusiveMinimum=Q.value}),A._zod.check=(E)=>{if(Q.inclusive?E.value>=Q.value:E.value>Q.value)return;E.issues.push({origin:VX[typeof E.value]??B,code:"too_small",minimum:typeof Q.value==="object"?Q.value.getTime():Q.value,input:E.value,inclusive:Q.inclusive,inst:A,continue:!Q.abort})}}),sp=JA("$ZodCheckMultipleOf",(A,Q)=>{PI.init(A,Q),A._zod.onattach.push((B)=>{var E;(E=B._zod.bag).multipleOf??(E.multipleOf=Q.value)}),A._zod.check=(B)=>{if(typeof B.value!==typeof Q.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof B.value==="bigint"?Q.value!==BigInt(0)&&B.value%Q.value===BigInt(0):x_(B.value,Q.value)===0)return;B.issues.push({origin:typeof B.value,code:"not_multiple_of",divisor:Q.value,input:B.value,inst:A,continue:!Q.abort})}}),tp=JA("$ZodCheckNumberFormat",(A,Q)=>{PI.init(A,Q),Q.format=Q.format||"float64";let B=Q.format?.includes("int"),E=B?"int":"number",[I,D]=c_[Q.format];A._zod.onattach.push((J)=>{let G=J._zod.bag;if(G.format=Q.format,G.minimum=I,G.maximum=D,B)G.pattern=MX}),A._zod.check=(J)=>{let G=J.value;if(B){if(!Number.isInteger(G)){J.issues.push({expected:E,format:Q.format,code:"invalid_type",continue:!1,input:G,inst:A});return}if(!Number.isSafeInteger(G)){if(G>0)J.issues.push({input:G,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:A,origin:E,inclusive:!0,continue:!Q.abort});else J.issues.push({input:G,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:A,origin:E,inclusive:!0,continue:!Q.abort});return}}if(G<I)J.issues.push({origin:"number",input:G,code:"too_small",minimum:I,inclusive:!0,inst:A,continue:!Q.abort});if(G>D)J.issues.push({origin:"number",input:G,code:"too_big",maximum:D,inclusive:!0,inst:A,continue:!Q.abort})}}),ep=JA("$ZodCheckMaxLength",(A,Q)=>{var B;PI.init(A,Q),(B=A._zod.def).when??(B.when=JO),A._zod.onattach.push((E)=>{let I=E._zod.bag.maximum??Number.POSITIVE_INFINITY;if(Q.maximum<I)E._zod.bag.maximum=Q.maximum}),A._zod.check=(E)=>{let I=E.value,D=I.length;if((typeof I==="string"&&D>Q.maximum?TY(I):D)<=Q.maximum)return;let G=PY(I);E.issues.push({origin:G,code:"too_big",maximum:Q.maximum,inclusive:!0,input:I,inst:A,continue:!Q.abort})}}),Ad=JA("$ZodCheckMinLength",(A,Q)=>{var B;PI.init(A,Q),(B=A._zod.def).when??(B.when=JO),A._zod.onattach.push((E)=>{let I=E._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(Q.minimum>I)E._zod.bag.minimum=Q.minimum}),A._zod.check=(E)=>{let I=E.value,D=I.length;if((typeof I==="string"&&D>=Q.minimum&&D<Q.minimum*2?TY(I):D)>=Q.minimum)return;let G=PY(I);E.issues.push({origin:G,code:"too_small",minimum:Q.minimum,inclusive:!0,input:I,inst:A,continue:!Q.abort})}}),Qd=JA("$ZodCheckLengthEquals",(A,Q)=>{var B;PI.init(A,Q),(B=A._zod.def).when??(B.when=JO),A._zod.onattach.push((E)=>{let I=E._zod.bag;I.minimum=Q.length,I.maximum=Q.length,I.length=Q.length}),A._zod.check=(E)=>{let I=E.value,D=I.length,J=typeof I==="string"&&D>=Q.length&&D<=Q.length*2?TY(I):D;if(J===Q.length)return;let G=PY(I),U=J>Q.length;E.issues.push({origin:G,...U?{code:"too_big",maximum:Q.length}:{code:"too_small",minimum:Q.length},inclusive:!0,exact:!0,input:E.value,inst:A,continue:!Q.abort})}}),xY=JA("$ZodCheckStringFormat",(A,Q)=>{var B,E;if(PI.init(A,Q),A._zod.onattach.push((I)=>{let D=I._zod.bag;if(D.format=Q.format,Q.pattern)D.patterns??(D.patterns=new Set),D.patterns.add(Q.pattern)}),Q.pattern)(B=A._zod).check??(B.check=(I)=>{if(Q.pattern.lastIndex=0,Q.pattern.test(I.value))return;I.issues.push({origin:"string",code:"invalid_format",format:Q.format,input:I.value,...Q.pattern?{pattern:Q.pattern.toString()}:{},inst:A,continue:!Q.abort})});else(E=A._zod).check??(E.check=()=>{})}),Bd=JA("$ZodCheckRegex",(A,Q)=>{xY.init(A,Q),A._zod.check=(B)=>{if(Q.pattern.lastIndex=0,Q.pattern.test(B.value))return;B.issues.push({origin:"string",code:"invalid_format",format:"regex",input:B.value,pattern:Q.pattern.toString(),inst:A,continue:!Q.abort})}}),Id=JA("$ZodCheckLowerCase",(A,Q)=>{Q.pattern??(Q.pattern=op),xY.init(A,Q)}),Ed=JA("$ZodCheckUpperCase",(A,Q)=>{Q.pattern??(Q.pattern=rp),xY.init(A,Q)}),Dd=JA("$ZodCheckIncludes",(A,Q)=>{PI.init(A,Q);let B=i8(Q.includes),E=new RegExp(typeof Q.position==="number"?`^.{${Q.position},}${B}`:B);Q.pattern=E,A._zod.onattach.push((I)=>{let D=I._zod.bag;D.patterns??(D.patterns=new Set),D.patterns.add(E)}),A._zod.check=(I)=>{if(I.value.includes(Q.includes,Q.position))return;I.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:Q.includes,input:I.value,inst:A,continue:!Q.abort})}}),Jd=JA("$ZodCheckStartsWith",(A,Q)=>{PI.init(A,Q);let B=new RegExp(`^${i8(Q.prefix)}.*`);Q.pattern??(Q.pattern=B),A._zod.onattach.push((E)=>{let I=E._zod.bag;I.patterns??(I.patterns=new Set),I.patterns.add(B)}),A._zod.check=(E)=>{if(E.value.startsWith(Q.prefix))return;E.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:Q.prefix,input:E.value,inst:A,continue:!Q.abort})}}),Gd=JA("$ZodCheckEndsWith",(A,Q)=>{PI.init(A,Q);let B=new RegExp(`.*${i8(Q.suffix)}$`);Q.pattern??(Q.pattern=B),A._zod.onattach.push((E)=>{let I=E._zod.bag;I.patterns??(I.patterns=new Set),I.patterns.add(B)}),A._zod.check=(E)=>{if(E.value.endsWith(Q.suffix))return;E.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:Q.suffix,input:E.value,inst:A,continue:!Q.abort})}}),Cd=JA("$ZodCheckOverwrite",(A,Q)=>{PI.init(A,Q),A._zod.check=(B)=>{B.value=Q.tx(B.value)}})});class $O{constructor(A=[],Q={}){this.content=[],this.indent=0,this.args=A,this.closed=Q}indented(A){this.indent+=1,A(this),this.indent-=1}write(A){if(typeof A==="function"){A(this,{execution:"sync"}),A(this,{execution:"async"});return}let B=A.split(`
7
+ `:"•")}}let D;try{return await new Promise((J,G)=>{D=()=>G(new n("Cancelled.",y.cancelled)),Q.signal?.addEventListener("abort",D,{once:!0}),I.once("SIGINT",D),I.question(A,(U)=>J(U.trim()))})}finally{if(D)Q.signal?.removeEventListener("abort",D);I.close()}}async function oG(A=process.stdin){if(A.isTTY)return"";let Q=[];for await(let B of A)Q.push(Buffer.isBuffer(B)?B:Buffer.from(String(B)));return Buffer.concat(Q).toString("utf8")}var XVA;var C4=W(()=>{wQ();XVA={bold:[1,22],dim:[2,22],italic:[3,23],underline:[4,24],red:[31,39],green:[32,39],yellow:[33,39],blue:[34,39],magenta:[35,39],cyan:[36,39],gray:[90,39]}});var DI="0.3.5",ol;var l8=W(()=>{ol=`oatmilk-cli/0.3.5 (${process.platform}; node ${process.versions.node})`});function p8(A=process.env){return{"user-agent":ol,...A.OATMILK_PROTECTION_BYPASS?{"x-vercel-protection-bypass":A.OATMILK_PROTECTION_BYPASS}:{}}}function sl(A,Q=process.env,B=fetch){return(E,I)=>{if(new URL(E instanceof Request?E.url:String(E)).origin!==A)return B(E,I);let J=new Headers(E instanceof Request?E.headers:void 0);for(let[G,U]of new Headers(I?.headers))J.set(G,U);for(let[G,U]of Object.entries(p8(Q)))if(!J.has(G))J.set(G,U);return B(E,{...I,headers:J})}}var D6=W(()=>{l8()});async function ZVA(A){return(await w_).getRandomValues(new Uint8Array(A))}async function NVA(A){let B=Math.pow(2,8)-Math.pow(2,8)%66,E="";while(E.length<A){let I=await ZVA(A-E.length);for(let D of I)if(D<B)E+="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._~"[D%66]}return E}async function zVA(A){return await NVA(A)}async function qVA(A){let Q=await(await w_).subtle.digest("SHA-256",new TextEncoder().encode(A));return btoa(String.fromCharCode(...new Uint8Array(Q))).replace(/\//g,"_").replace(/\+/g,"-").replace(/=/g,"")}async function v_(A){if(!A)A=43;if(A<43||A>128)throw`Expected a length between 43 and 128. Received ${A}.`;let Q=await zVA(A),B=await qVA(Q);return{code_verifier:Q,code_challenge:B}}var w_;var tl=W(()=>{w_=globalThis.crypto?.webcrypto??globalThis.crypto??import("node:crypto").then((A)=>A.webcrypto)});var cQ={};pQ(cQ,{unwrapMessage:()=>J6,uint8ArrayToHex:()=>pVA,uint8ArrayToBase64url:()=>cVA,uint8ArrayToBase64:()=>Gp,toZod:()=>Ap,stringifyPrimitive:()=>HX,slugify:()=>f_,shallowClone:()=>Bp,safeExtend:()=>kVA,required:()=>fVA,randomString:()=>gVA,propertyKeyTypes:()=>u_,promiseAllObject:()=>RVA,primitiveTypes:()=>Ip,prefixIssues:()=>n8,pick:()=>wVA,partial:()=>yVA,parsedType:()=>p_,own:()=>G6,optionalKeys:()=>m_,omit:()=>vVA,objectClone:()=>LVA,numKeys:()=>TVA,nullish:()=>k_,normalizeParams:()=>KQ,mergeDefs:()=>d8,merge:()=>xVA,members:()=>d_,jsonStringifyReplacer:()=>C6,joinValues:()=>YX,issue:()=>U6,isPlainObject:()=>BJ,isObject:()=>rG,installLazyProp:()=>aVA,hide:()=>i_,hexToUint8Array:()=>lVA,getSizableOrigin:()=>Dp,getParsedType:()=>PVA,getLengthableOrigin:()=>PY,getEnumValues:()=>RY,getElementAtPath:()=>jVA,floatSafeRemainder:()=>x_,finalizeIssue:()=>M1,extend:()=>bVA,explicitlyAborted:()=>l_,escapeRegex:()=>i8,esc:()=>y_,defineLazyInternal:()=>TB,defineLazy:()=>Qp,createTransparentProxy:()=>SVA,constantCatch:()=>Up,codePointLength:()=>TY,cloneDef:()=>WVA,clone:()=>y4,cleanRegex:()=>gY,cleanEnum:()=>uVA,captureStackTrace:()=>KX,cached:()=>$6,base64urlToUint8Array:()=>mVA,base64ToUint8Array:()=>Jp,attachSchema:()=>XX,assignProp:()=>JI,assertNotEqual:()=>MVA,assertNever:()=>_VA,assertIs:()=>VVA,assertEqual:()=>FVA,assert:()=>OVA,allowsEval:()=>h_,aborted:()=>IJ,NUMBER_FORMAT_RANGES:()=>c_,Class:()=>Cp,CONSTANT_CATCH:()=>$p,BIGINT_FORMAT_RANGES:()=>Ep});function FVA(A){return A}function MVA(A){return A}function Ap(){return(A)=>A}function VVA(A){}function _VA(A){throw Error("Unexpected value in exhaustive check")}function OVA(A){}function RY(A){let Q=Object.values(A).filter((E)=>typeof E==="number");return Object.entries(A).filter(([E,I])=>Q.indexOf(+E)===-1).map(([E,I])=>I)}function YX(A,Q="|"){return A.map((B)=>HX(B)).join(Q)}function C6(A,Q){if(typeof Q==="bigint")return Q.toString();return Q}function $6(A){return{get value(){{let B=A();return Object.defineProperty(this,"value",{value:B}),B}throw Error("cached value already set")}}}function k_(A){return A===null||A===void 0}function gY(A){let Q=A.startsWith("^")?1:0,B=A.endsWith("$")?A.length-1:A.length;return A.slice(Q,B)}function x_(A,Q){let B=A/Q,E=Math.round(B),I=4*Number.EPSILON*Math.max(Math.abs(B),1);if(Math.abs(B-E)<I)return 0;return B-E}function Qp(A,Q,B){let E=void 0;Object.defineProperty(A,Q,{get(){if(E===el)return;if(E===void 0)E=el,E=B();return E},set(I){Object.defineProperty(A,Q,{value:I})},configurable:!0})}function LVA(A){return Object.create(Object.getPrototypeOf(A),Object.getOwnPropertyDescriptors(A))}function JI(A,Q,B){Object.defineProperty(A,Q,{value:B,writable:!0,enumerable:!0,configurable:!0})}function d8(...A){let Q={};for(let B of A){let E=Object.getOwnPropertyDescriptors(B);Object.assign(Q,E)}return Object.defineProperties({},Q)}function WVA(A){return d8(A._zod.def)}function jVA(A,Q){if(!Q)return A;return Q.reduce((B,E)=>B?.[E],A)}function RVA(A){let Q=Object.keys(A),B=Q.map((E)=>A[E]);return Promise.all(B).then((E)=>{let I={};for(let D=0;D<Q.length;D++)I[Q[D]]=E[D];return I})}function gVA(A=10){let B="";for(let E=0;E<A;E++)B+="abcdefghijklmnopqrstuvwxyz"[Math.floor(Math.random()*26)];return B}function y_(A){return JSON.stringify(A)}function f_(A){return A.toLowerCase().trim().replace(/[^\w\s-]/g,"").replace(/[\s_-]+/g,"-").replace(/^-+|-+$/g,"")}function rG(A){return typeof A==="object"&&A!==null&&!Array.isArray(A)}function BJ(A){if(rG(A)===!1)return!1;let Q=A.constructor;if(Q===void 0)return!0;if(typeof Q!=="function")return!0;let B=Q.prototype;if(rG(B)===!1)return!1;if(Object.prototype.hasOwnProperty.call(B,"isPrototypeOf")===!1)return!1;return!0}function Bp(A){if(BJ(A))return{...A};if(Array.isArray(A))return[...A];if(A instanceof Map)return new Map(A);if(A instanceof Set)return new Set(A);return A}function TVA(A){let Q=0;for(let B in A)if(Object.prototype.hasOwnProperty.call(A,B))Q++;return Q}function i8(A){return A.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}function y4(A,Q,B){let E=new A._zod.constr(Q??A._zod.def);if(!Q||B?.parent)E._zod.parent=A;return E}function KQ(A){let Q=A;if(!Q)return{};if(typeof Q==="string")return{error:()=>Q};if(Q?.message!==void 0){if(Q?.error!==void 0)throw Error("Cannot specify both `message` and `error` params");Q.error=Q.message}if(delete Q.message,typeof Q.error==="string")return{...Q,error:()=>Q.error};return Q}function SVA(A){let Q;return new Proxy({},{get(B,E,I){return Q??(Q=A()),Reflect.get(Q,E,I)},set(B,E,I,D){return Q??(Q=A()),Reflect.set(Q,E,I,D)},has(B,E){return Q??(Q=A()),Reflect.has(Q,E)},deleteProperty(B,E){return Q??(Q=A()),Reflect.deleteProperty(Q,E)},ownKeys(B){return Q??(Q=A()),Reflect.ownKeys(Q)},getOwnPropertyDescriptor(B,E){return Q??(Q=A()),Reflect.getOwnPropertyDescriptor(Q,E)},defineProperty(B,E,I){return Q??(Q=A()),Reflect.defineProperty(Q,E,I)}})}function HX(A){if(typeof A==="bigint")return A.toString()+"n";if(typeof A==="string")return`"${A}"`;return`${A}`}function m_(A){return Object.keys(A).filter((Q)=>{return A[Q]._zod.optin!==void 0&&A[Q]._zod.optout==="optional"})}function wVA(A,Q){let B=A._zod.def,E=B.checks;if(E&&E.length>0)throw Error(".pick() cannot be used on object schemas containing refinements");let D=d8(A._zod.def,{get shape(){let J={};for(let G of Reflect.ownKeys(Q)){if(!Object.prototype.hasOwnProperty.call(B.shape,G))throw Error(`Unrecognized key: "${String(G)}"`);if(!Q[G])continue;JI(J,G,B.shape[G])}return JI(this,"shape",J),J},checks:[]});return y4(A,D)}function vVA(A,Q){let B=A._zod.def,E=B.checks;if(E&&E.length>0)throw Error(".omit() cannot be used on object schemas containing refinements");let D=d8(A._zod.def,{get shape(){let J={...A._zod.def.shape};for(let G of Reflect.ownKeys(Q)){if(!Object.prototype.hasOwnProperty.call(B.shape,G))throw Error(`Unrecognized key: "${String(G)}"`);if(!Q[G])continue;delete J[G]}return JI(this,"shape",J),J},checks:[]});return y4(A,D)}function bVA(A,Q){if(!BJ(Q))throw Error("Invalid input to extend: expected a plain object");let B=A._zod.def.checks;if(B&&B.length>0){let D=A._zod.def.shape;for(let J of Reflect.ownKeys(Q))if(Object.getOwnPropertyDescriptor(D,J)!==void 0)throw Error("Cannot overwrite keys on object schemas containing refinements. Use `.safeExtend()` instead.")}let I=d8(A._zod.def,{get shape(){let D={...A._zod.def.shape,...Q};return JI(this,"shape",D),D}});return y4(A,I)}function kVA(A,Q){if(!BJ(Q))throw Error("Invalid input to safeExtend: expected a plain object");let B=d8(A._zod.def,{get shape(){let E={...A._zod.def.shape,...Q};return JI(this,"shape",E),E}});return y4(A,B)}function xVA(A,Q){if(!Q?._zod?.def)throw Error("Invalid input to merge: expected an object schema. To merge a plain shape, use `.extend()`.");if(A._zod.def.checks?.length)throw Error(".merge() cannot be used on object schemas containing refinements. Use .safeExtend() instead.");let B=d8(A._zod.def,{get shape(){let E={...A._zod.def.shape,...Q._zod.def.shape};return JI(this,"shape",E),E},get catchall(){return Q._zod.def.catchall},checks:Q._zod.def.checks??[]});return y4(A,B)}function yVA(A,Q,B,E="partial"){let D=Q._zod.def.checks;if(D&&D.length>0)throw Error(`.${E}() cannot be used on object schemas containing refinements`);let G=d8(Q._zod.def,{get shape(){let U=Q._zod.def.shape,Y={...U};if(B)for(let H of Reflect.ownKeys(B)){if(!Object.prototype.hasOwnProperty.call(U,H))throw Error(`Unrecognized key: "${String(H)}"`);if(!B[H])continue;Y[H]=A?new A({type:"optional",innerType:U[H]}):U[H]}else for(let H of Reflect.ownKeys(U))Y[H]=A?new A({type:"optional",innerType:U[H]}):U[H];return JI(this,"shape",Y),Y},checks:[]});return y4(Q,G)}function fVA(A,Q,B){let E=d8(Q._zod.def,{get shape(){let I=Q._zod.def.shape,D={...I};if(B)for(let J of Reflect.ownKeys(B)){if(!Object.prototype.hasOwnProperty.call(D,J))throw Error(`Unrecognized key: "${String(J)}"`);if(!B[J])continue;D[J]=new A({type:"nonoptional",innerType:I[J]})}else for(let J of Reflect.ownKeys(I))D[J]=new A({type:"nonoptional",innerType:I[J]});return JI(this,"shape",D),D}});return y4(Q,E)}function IJ(A,Q=0){if(A.aborted===!0)return!0;for(let B=Q;B<A.issues.length;B++)if(A.issues[B]?.continue!==!0)return!0;return!1}function l_(A,Q=0){if(A.aborted===!0)return!0;for(let B=Q;B<A.issues.length;B++)if(A.issues[B]?.continue===!1)return!0;return!1}function n8(A,Q){return Q.map((B)=>{var E;return(E=B).path??(E.path=[]),B.path.unshift(A),B})}function J6(A){return typeof A==="string"?A:A?.message}function XX(A,Q,B){var E;for(let I=Q;I<A.length;I++)(E=A[I]).schema??(E.schema=B)}function M1(A,Q,B){var E;let I=A.inst?._zod?.traits;if(I?.has("$ZodType"))if(I.has("$ZodCheck"))(E=A).schema??(E.schema=A.inst);else A.schema=A.inst;let D=A.schema!==A.inst?A.schema?._zod.def?.error:void 0,J=A.message?A.message:J6(A.inst?._zod.def?.error?.(A))??J6(D?.(A))??J6(Q?.error?.(A))??J6(B.customError?.(A))??J6(B.localeError?.(A))??"Invalid input",{inst:G,schema:U,continue:Y,input:H,...X}=A;if(X.path??(X.path=[]),X.message=J,Q?.reportInput)X.input=H;return X}function Dp(A){if(A instanceof Set)return"set";if(A instanceof Map)return"map";if(A instanceof File)return"file";return"unknown"}function TY(A){let Q=A.length;if(!hVA.test(A))return Q;let B=Q;for(let E=0;E<Q-1;E++)if((A.charCodeAt(E)&64512)===55296&&(A.charCodeAt(E+1)&64512)===56320)B--,E++;return B}function PY(A){if(Array.isArray(A))return"array";if(typeof A==="string")return"string";return"unknown"}function p_(A){let Q=typeof A;switch(Q){case"number":return Number.isNaN(A)?"nan":"number";case"object":{if(A===null)return"null";if(Array.isArray(A))return"array";let B=A;if(B&&Object.getPrototypeOf(B)!==Object.prototype&&"constructor"in B&&B.constructor)return B.constructor.name}}return Q}function U6(...A){let[Q,B,E]=A;if(typeof Q==="string")return{message:Q,code:"custom",input:B,inst:E};return{...Q}}function uVA(A){return Object.entries(A).filter(([Q,B])=>{return Number.isNaN(Number.parseInt(Q,10))}).map((Q)=>Q[1])}function Jp(A){let Q=atob(A),B=new Uint8Array(Q.length);for(let E=0;E<Q.length;E++)B[E]=Q.charCodeAt(E);return B}function Gp(A){let Q="";for(let B=0;B<A.length;B++)Q+=String.fromCharCode(A[B]);return btoa(Q)}function mVA(A){let Q=A.replace(/-/g,"+").replace(/_/g,"/"),B="=".repeat((4-Q.length%4)%4);return Jp(Q+B)}function cVA(A){return Gp(A).replace(/\+/g,"-").replace(/\//g,"_").replace(/=/g,"")}function lVA(A){let Q=A.replace(/^0x/,"");if(Q.length%2!==0)throw Error("Invalid hex string length");let B=new Uint8Array(Q.length/2);for(let E=0;E<Q.length;E+=2)B[E/2]=Number.parseInt(Q.slice(E,E+2),16);return B}function pVA(A){return Array.from(A).map((Q)=>Q.toString(16).padStart(2,"0")).join("")}class Cp{constructor(...A){}}function d_(A,Q){for(let B in Q){let E=Object.getOwnPropertyDescriptor(Q,B);if(E.get)Object.defineProperty(A,B,{...E,enumerable:!1});else dVA(A,B,E.value)}}function G6(A,Q,B,E=!0){return Object.defineProperty(A,Q,{configurable:!0,writable:!0,enumerable:E,value:B}),B}function i_(A,Q,B){return G6(A,Q,B,!1)}function dVA(A,Q,B){Object.defineProperty(A,Q,{configurable:!0,get(){return this==null?B:G6(this,Q,B.bind(this))},set(E){G6(this,Q,E)}})}function iVA(A,Q){let B=Object.getPrototypeOf(A);return Q in B?void 0:B}function TB(A,Q,B){let E=Object.getPrototypeOf(A._zod);if(Q in E&&b_!==A._zod){b_=void 0;return}b_=A._zod,Object.defineProperty(E,Q,{configurable:!0,get(){Object.defineProperty(this,Q,nVA);let I=QJ;QJ=!1;try{let D=B(this);if(QJ)delete this[Q];else Object.defineProperty(this,Q,{configurable:!0,writable:!0,value:D});return QJ=QJ||I,D}catch(D){throw delete this[Q],QJ=QJ||I,D}},set(I){Object.defineProperty(this,Q,{configurable:!0,writable:!0,value:I})}})}function aVA(A,Q,B,E){let I=iVA(A,Q);if(!I)return;Object.defineProperty(I,Q,{configurable:!0,get(){let D={configurable:!0,writable:!0,enumerable:E,value:void 0};return Object.defineProperty(this,Q,D),D.value=B(this),Object.defineProperty(this,Q,D),D.value},set(D){Object.defineProperty(this,Q,{configurable:!0,writable:!0,enumerable:E,value:D})}})}function Up(A){let Q=()=>A;return Q[$p]=!0,Q}var el,KX,h_,PVA=(A)=>{let Q=typeof A;switch(Q){case"undefined":return"undefined";case"string":return"string";case"number":return Number.isNaN(A)?"nan":"number";case"boolean":return"boolean";case"function":return"function";case"bigint":return"bigint";case"symbol":return"symbol";case"object":if(Array.isArray(A))return"array";if(A===null)return"null";if(A.then&&typeof A.then==="function"&&A.catch&&typeof A.catch==="function")return"promise";if(typeof Map<"u"&&A instanceof Map)return"map";if(typeof Set<"u"&&A instanceof Set)return"set";if(typeof Date<"u"&&A instanceof Date)return"date";if(typeof File<"u"&&A instanceof File)return"file";return"object";default:throw Error(`Unknown data type: ${Q}`)}},u_,Ip,c_,Ep,hVA,b_,QJ=!1,nVA,$p="~constantCatch";var $4=W(()=>{sG();el=Symbol("evaluating");KX="captureStackTrace"in Error?Error.captureStackTrace:(...A)=>{};h_=$6(()=>{if(RE.jitless)return!1;if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{return new Function(""),!0}catch(A){return!1}});u_=new Set(["string","number","symbol"]),Ip=new Set(["string","number","bigint","boolean","symbol","undefined"]);c_=(()=>({safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-340282346638528860000000000000000000000,340282346638528860000000000000000000000],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]}))(),Ep={int64:[BigInt("-9223372036854775808"),BigInt("9223372036854775807")],uint64:[BigInt(0),BigInt("18446744073709551615")]};hVA=/[\uD800-\uDBFF]/;nVA={configurable:!0,get(){QJ=!0;return}}});function oVA(A){let Q=Kp;if(Q){let B=Q.stackTraceLimit;if(typeof B==="number"){try{Q.stackTraceLimit=0}catch{return Kp=null,new A}try{return new A}finally{Q.stackTraceLimit=B}}}return new A}function JA(A,Q,B,E){let I={};function D(N){this.def=N,this.constr=X,this.traits=new Set}D.prototype=I;let J=B,G=J&&new WeakSet;function U(N,z){if(!N._zod){n_.value=new D(z);try{Object.defineProperty(N,"_zod",n_)}finally{n_.value=void 0}}if(N._zod.traits.has(A))return;if(N._zod.traits.add(A),Q(N,z),G){let V=Object.getPrototypeOf(N),O=N._zod.constr.prototype,j=V;while(j&&j!==O)j=Object.getPrototypeOf(j);let b=j??V;if(!G.has(b))G.add(b),d_(b,J)}let F=X.prototype;for(let V in F){if(!Object.prototype.hasOwnProperty.call(F,V))continue;if(!(V in N))N[V]=F[V].bind(N)}}let Y=E?.Parent??Object;class H extends Y{}Object.defineProperty(H,"name",{value:A});function X(N){let z=E?.Parent?oVA(H):this;U(z,N);let F=z._zod.deferred;if(F){for(let O of F)O();z._zod.deferred=void 0}let V=globalThis.__zod_globalConfig?.postProcessor;if(V)V(z);return z}return Object.defineProperty(X,"init",{value:U}),Object.defineProperty(X,Symbol.hasInstance,{value:(N)=>{if(E?.Parent&&N instanceof E.Parent)return!0;return N?._zod?.traits?.has(A)}}),Object.defineProperty(X,"name",{value:A}),X}function gE(A){if(A)Object.assign(RE,A);return RE}var Yp,a_,n_,Kp,a8,SY,RE;var sG=W(()=>{$4();a_=Object.freeze({status:"aborted"}),n_={value:void 0,enumerable:!1},Kp="captureStackTrace"in Error?Error:null;a8=class a8 extends Error{constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}};SY=class SY extends Error{constructor(A){super(`Encountered unidirectional transform during encode: ${A}`);this.name="ZodEncodeError"}};(Yp=globalThis).__zod_globalConfig??(Yp.__zod_globalConfig={});RE=globalThis.__zod_globalConfig});function rVA(){let A=this._zod;return A.message??(A.message=JSON.stringify(A.def,C6,2)),A.message}function sVA(A){this._zod.message=A}function eVA(A,Q,B){if(!Object.prototype.hasOwnProperty.call(A,Q))if(Q==="__proto__")Object.defineProperty(A,Q,{value:B(),writable:!0,enumerable:!0,configurable:!0});else A[Q]=B();return A[Q]}function e_(A,Q=(B)=>B.message){let B={},E=[];for(let I of A.issues)if(I.path.length>0)eVA(B,I.path[0],()=>[]).push(Q(I));else E.push(Q(I));return{formErrors:E,fieldErrors:B}}function AO(A,Q=(B)=>B.message){let B={_errors:[]},E=(I,D=[])=>{for(let J of I.issues)if(J.code==="invalid_union"&&J.errors.length)J.errors.map((G)=>E({issues:G},[...D,...J.path]));else if(J.code==="invalid_key")E({issues:J.issues},[...D,...J.path]);else if(J.code==="invalid_element")E({issues:J.issues},[...D,...J.path]);else{let G=[...D,...J.path];if(G.length===0)B._errors.push(Q(J));else{let U=B,Y=0;while(Y<G.length){let H=G[Y],X=Y===G.length-1;if(H==="_errors"){if(X)U._errors.push(Q(J));Y++;continue}if(!Object.prototype.hasOwnProperty.call(U,H))Object.defineProperty(U,H,{value:{_errors:[]},enumerable:!0,writable:!0,configurable:!0});let N=U[H];if(X)N._errors.push(Q(J));U=N,Y++}}}};return E(A),B}var tVA,r_,s_,Hp,Xp=(A,Q)=>{A.name="$ZodError",r_.value=A._zod,Object.defineProperty(A,"_zod",r_),s_.value=Q,Object.defineProperty(A,"issues",s_),r_.value=void 0,s_.value=void 0,Object.defineProperty(A,"message",tVA);let B=Object.getPrototypeOf(A);if(!Hp.has(B))Hp.add(B),Object.defineProperty(B,"toString",{configurable:!0,enumerable:!1,get(){let E=()=>this.message;return Object.defineProperty(this,"toString",{value:E,configurable:!0,writable:!0}),E},set(E){Object.defineProperty(this,"toString",{value:E,configurable:!0,writable:!0})}})},ZX,t_;var QO=W(()=>{sG();$4();tVA={get:rVA,set:sVA,enumerable:!0,configurable:!0},r_={value:void 0,enumerable:!1},s_={value:void 0,enumerable:!1},Hp=new WeakSet([Object.prototype,Error.prototype]),ZX=JA("$ZodError",Xp),t_=JA("$ZodError",Xp,void 0,{Parent:Error})});function NX(A,Q){return{callee:Q?.callee??A,Err:Q?.Err}}var zX=(A)=>{let Q=(B,E,I,D)=>{let J=I?{...I,async:!1}:{async:!1},G=B._zod.run({value:E,issues:[]},J);if(G instanceof Promise)throw new a8;if(G.issues.length){let U=new(D?.Err??A)(G.issues.map((Y)=>M1(Y,J,gE())));throw KX(U,D?.callee??Q),U}return G.value};return Q},qX=(A)=>{let Q=async(B,E,I,D)=>{let J=I?{...I,async:!0}:{async:!0},G=B._zod.run({value:E,issues:[]},J);if(G instanceof Promise)G=await G;if(G.issues.length){let U=new(D?.Err??A)(G.issues.map((Y)=>M1(Y,J,gE())));throw KX(U,D?.callee??Q),U}return G.value};return Q},wY=(A)=>(Q,B,E)=>{let I=E?{...E,async:!1}:{async:!1},D=Q._zod.run({value:B,issues:[]},I);if(D instanceof Promise)throw new a8;return D.issues.length?{success:!1,error:new(A??ZX)(D.issues.map((J)=>M1(J,I,gE())))}:{success:!0,data:D.value}},vY,bY=(A)=>async(Q,B,E)=>{let I=E?{...E,async:!0}:{async:!0},D=Q._zod.run({value:B,issues:[]},I);if(D instanceof Promise)D=await D;return D.issues.length?{success:!1,error:new A(D.issues.map((J)=>M1(J,I,gE())))}:{success:!0,data:D.value}},FX,Zp=(A)=>{let Q=zX(A),B=(E,I,D,J)=>{let G=D?{...D,direction:"backward"}:{direction:"backward"};return Q(E,I,G,NX(B,J))};return B},Np=(A)=>{let Q=zX(A),B=(E,I,D,J)=>{return Q(E,I,D,NX(B,J))};return B},zp=(A)=>{let Q=qX(A),B=async(E,I,D,J)=>{let G=D?{...D,direction:"backward"}:{direction:"backward"};return await Q(E,I,G,NX(B,J))};return B},qp=(A)=>{let Q=qX(A),B=async(E,I,D,J)=>{return await Q(E,I,D,NX(B,J))};return B},Fp=(A)=>(Q,B,E)=>{let I=E?{...E,direction:"backward"}:{direction:"backward"};return wY(A)(Q,B,I)},Mp=(A)=>(Q,B,E)=>{return wY(A)(Q,B,E)},Vp=(A)=>async(Q,B,E)=>{let I=E?{...E,direction:"backward"}:{direction:"backward"};return bY(A)(Q,B,I)},_p=(A)=>async(Q,B,E)=>{return bY(A)(Q,B,E)};var BO=W(()=>{sG();QO();$4();vY=wY(t_),FX=bY(t_)});function Tp(A){return new RegExp(`^[a-zA-Z0-9_-]{${A}}$`)}function vp(){return new RegExp(Q_A,"u")}function B_A(A){return new RegExp(`^${A}$`)}function IO(A){return typeof A.precision==="number"?A.precision===-1?"(?:[01]\\d|2[0-3]):[0-5]\\d":A.precision===0?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d":`(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d\\.\\d{${A.precision}}`:A.seconds?"(?:[01]\\d|2[0-3]):[0-5]\\d:[0-5]\\d(?:\\.\\d+)?":"(?:[01]\\d|2[0-3]):[0-5]\\d(?::[0-5]\\d(?:\\.\\d+)?)?"}function lp(A){return new RegExp(`^${IO(A)}$`)}function pp(A){let Q=["Z"];if(A.offset)Q.push("([+-](?:[01]\\d|2[0-3]):[0-5]\\d)");let B=`${IO({precision:A.precision,seconds:!0})}(?:${Q.join("|")})`,E=A.local?`${B}|${IO({precision:A.precision})}`:B;return new RegExp(`^${mp}T(?:${E})$`)}var Op,Lp,Wp,jp,Rp,gp,Pp,Sp,EO=(A)=>{if(!A)return/^([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|ffffffff-ffff-ffff-ffff-ffffffffffff)$/;return new RegExp(`^([0-9a-fA-F]{8}-[0-9a-fA-F]{4}-${A}[0-9a-fA-F]{3}-[89abAB][0-9a-fA-F]{3}-[0-9a-fA-F]{12})$`)},wp,Q_A="^[\\p{Extended_Pictographic}\\p{Emoji_Component}]+$",bp,kp,xp,yp,fp,DO,hp,up,mp="(?:(?:\\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])))",cp,dp=(A)=>{let Q=A?`[\\s\\S]{${A?.minimum??0},${A?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${Q}$`)},ip,MX,Y6,np,ap,op,rp;var kY=W(()=>{Op=/^[cC][0-9a-z]{6,}$/,Lp=/^[0-9a-z]+$/,Wp=/^[0-7][0-9A-HJKMNP-TV-Za-hjkmnp-tv-z]{25}$/,jp=/^[0-9a-vA-V]{20}$/,Rp=/^[A-Za-z0-9]{27}$/,gp=/^[a-zA-Z0-9_-]{21}$/;Pp=/^P(?:(\d+W)|(?!.*W)(?=\d|T\d)(\d+Y)?(\d+M)?(\d+D)?(T(?=\d)(\d+H)?(\d+M)?(\d+([.,]\d+)?S)?)?)$/,Sp=/^([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})$/,wp=/^(?!\.)(?!.*\.\.)([A-Za-z0-9_'+\-\.]*)[A-Za-z0-9_+-]@([A-Za-z0-9][A-Za-z0-9\-]*\.)+[A-Za-z]{2,}$/;bp=/^(?:(?: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])$/,kp=/^(([0-9a-fA-F]{1,4}:){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}|:))$/,xp=/^((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])$/,yp=/^(([0-9a-fA-F]{1,4}:){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}|:))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,fp=/^$|^(?:[0-9a-zA-Z+/]{4})*(?:(?:[0-9a-zA-Z+/]{2}==)|(?:[0-9a-zA-Z+/]{3}=))?$/,DO=/^[A-Za-z0-9_-]*$/,hp=/^https?$/,up=/^\+[1-9]\d{6,14}$/;cp=B_A(mp);ip=/^-?\d+n?$/,MX=/^-?\d+$/,Y6=/^-?\d+(?:\.\d+)?$/,np=/^(?:true|false)$/i,ap=/^null$/i,op=/^[^A-Z]*$/,rp=/^[^a-z]*$/});var PI,JO=(A)=>{let Q=A.value;return!k_(Q)&&Q.length!==void 0},VX,GO,CO,sp,tp,ep,Ad,Qd,xY,Bd,Id,Ed,Dd,Jd,Gd,Cd;var _X=W(()=>{sG();kY();$4();PI=JA("$ZodCheck",(A,Q)=>{var B;A._zod??(A._zod={}),A._zod.def=Q,(B=A._zod).onattach??(B.onattach=[])}),VX={number:"number",bigint:"bigint",object:"date"},GO=JA("$ZodCheckLessThan",(A,Q)=>{PI.init(A,Q);let B=VX[typeof Q.value];A._zod.onattach.push((E)=>{let I=E._zod.bag,D=(Q.inclusive?I.maximum:I.exclusiveMaximum)??Number.POSITIVE_INFINITY;if(Q.value<D)if(Q.inclusive)I.maximum=Q.value;else I.exclusiveMaximum=Q.value}),A._zod.check=(E)=>{if(Q.inclusive?E.value<=Q.value:E.value<Q.value)return;E.issues.push({origin:VX[typeof E.value]??B,code:"too_big",maximum:typeof Q.value==="object"?Q.value.getTime():Q.value,input:E.value,inclusive:Q.inclusive,inst:A,continue:!Q.abort})}}),CO=JA("$ZodCheckGreaterThan",(A,Q)=>{PI.init(A,Q);let B=VX[typeof Q.value];A._zod.onattach.push((E)=>{let I=E._zod.bag,D=(Q.inclusive?I.minimum:I.exclusiveMinimum)??Number.NEGATIVE_INFINITY;if(Q.value>D)if(Q.inclusive)I.minimum=Q.value;else I.exclusiveMinimum=Q.value}),A._zod.check=(E)=>{if(Q.inclusive?E.value>=Q.value:E.value>Q.value)return;E.issues.push({origin:VX[typeof E.value]??B,code:"too_small",minimum:typeof Q.value==="object"?Q.value.getTime():Q.value,input:E.value,inclusive:Q.inclusive,inst:A,continue:!Q.abort})}}),sp=JA("$ZodCheckMultipleOf",(A,Q)=>{PI.init(A,Q),A._zod.onattach.push((B)=>{var E;(E=B._zod.bag).multipleOf??(E.multipleOf=Q.value)}),A._zod.check=(B)=>{if(typeof B.value!==typeof Q.value)throw Error("Cannot mix number and bigint in multiple_of check.");if(typeof B.value==="bigint"?Q.value!==BigInt(0)&&B.value%Q.value===BigInt(0):x_(B.value,Q.value)===0)return;B.issues.push({origin:typeof B.value,code:"not_multiple_of",divisor:Q.value,input:B.value,inst:A,continue:!Q.abort})}}),tp=JA("$ZodCheckNumberFormat",(A,Q)=>{PI.init(A,Q),Q.format=Q.format||"float64";let B=Q.format?.includes("int"),E=B?"int":"number",[I,D]=c_[Q.format];A._zod.onattach.push((J)=>{let G=J._zod.bag;if(G.format=Q.format,G.minimum=I,G.maximum=D,B)G.pattern=MX}),A._zod.check=(J)=>{let G=J.value;if(B){if(!Number.isInteger(G)){J.issues.push({expected:E,format:Q.format,code:"invalid_type",continue:!1,input:G,inst:A});return}if(!Number.isSafeInteger(G)){if(G>0)J.issues.push({input:G,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:A,origin:E,inclusive:!0,continue:!Q.abort});else J.issues.push({input:G,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:A,origin:E,inclusive:!0,continue:!Q.abort});return}}if(G<I)J.issues.push({origin:"number",input:G,code:"too_small",minimum:I,inclusive:!0,inst:A,continue:!Q.abort});if(G>D)J.issues.push({origin:"number",input:G,code:"too_big",maximum:D,inclusive:!0,inst:A,continue:!Q.abort})}}),ep=JA("$ZodCheckMaxLength",(A,Q)=>{var B;PI.init(A,Q),(B=A._zod.def).when??(B.when=JO),A._zod.onattach.push((E)=>{let I=E._zod.bag.maximum??Number.POSITIVE_INFINITY;if(Q.maximum<I)E._zod.bag.maximum=Q.maximum}),A._zod.check=(E)=>{let I=E.value,D=I.length;if((typeof I==="string"&&D>Q.maximum?TY(I):D)<=Q.maximum)return;let G=PY(I);E.issues.push({origin:G,code:"too_big",maximum:Q.maximum,inclusive:!0,input:I,inst:A,continue:!Q.abort})}}),Ad=JA("$ZodCheckMinLength",(A,Q)=>{var B;PI.init(A,Q),(B=A._zod.def).when??(B.when=JO),A._zod.onattach.push((E)=>{let I=E._zod.bag.minimum??Number.NEGATIVE_INFINITY;if(Q.minimum>I)E._zod.bag.minimum=Q.minimum}),A._zod.check=(E)=>{let I=E.value,D=I.length;if((typeof I==="string"&&D>=Q.minimum&&D<Q.minimum*2?TY(I):D)>=Q.minimum)return;let G=PY(I);E.issues.push({origin:G,code:"too_small",minimum:Q.minimum,inclusive:!0,input:I,inst:A,continue:!Q.abort})}}),Qd=JA("$ZodCheckLengthEquals",(A,Q)=>{var B;PI.init(A,Q),(B=A._zod.def).when??(B.when=JO),A._zod.onattach.push((E)=>{let I=E._zod.bag;I.minimum=Q.length,I.maximum=Q.length,I.length=Q.length}),A._zod.check=(E)=>{let I=E.value,D=I.length,J=typeof I==="string"&&D>=Q.length&&D<=Q.length*2?TY(I):D;if(J===Q.length)return;let G=PY(I),U=J>Q.length;E.issues.push({origin:G,...U?{code:"too_big",maximum:Q.length}:{code:"too_small",minimum:Q.length},inclusive:!0,exact:!0,input:E.value,inst:A,continue:!Q.abort})}}),xY=JA("$ZodCheckStringFormat",(A,Q)=>{var B,E;if(PI.init(A,Q),A._zod.onattach.push((I)=>{let D=I._zod.bag;if(D.format=Q.format,Q.pattern)D.patterns??(D.patterns=new Set),D.patterns.add(Q.pattern)}),Q.pattern)(B=A._zod).check??(B.check=(I)=>{if(Q.pattern.lastIndex=0,Q.pattern.test(I.value))return;I.issues.push({origin:"string",code:"invalid_format",format:Q.format,input:I.value,...Q.pattern?{pattern:Q.pattern.toString()}:{},inst:A,continue:!Q.abort})});else(E=A._zod).check??(E.check=()=>{})}),Bd=JA("$ZodCheckRegex",(A,Q)=>{xY.init(A,Q),A._zod.check=(B)=>{if(Q.pattern.lastIndex=0,Q.pattern.test(B.value))return;B.issues.push({origin:"string",code:"invalid_format",format:"regex",input:B.value,pattern:Q.pattern.toString(),inst:A,continue:!Q.abort})}}),Id=JA("$ZodCheckLowerCase",(A,Q)=>{Q.pattern??(Q.pattern=op),xY.init(A,Q)}),Ed=JA("$ZodCheckUpperCase",(A,Q)=>{Q.pattern??(Q.pattern=rp),xY.init(A,Q)}),Dd=JA("$ZodCheckIncludes",(A,Q)=>{PI.init(A,Q);let B=i8(Q.includes),E=new RegExp(typeof Q.position==="number"?`^.{${Q.position},}${B}`:B);Q.pattern=E,A._zod.onattach.push((I)=>{let D=I._zod.bag;D.patterns??(D.patterns=new Set),D.patterns.add(E)}),A._zod.check=(I)=>{if(I.value.includes(Q.includes,Q.position))return;I.issues.push({origin:"string",code:"invalid_format",format:"includes",includes:Q.includes,input:I.value,inst:A,continue:!Q.abort})}}),Jd=JA("$ZodCheckStartsWith",(A,Q)=>{PI.init(A,Q);let B=new RegExp(`^${i8(Q.prefix)}.*`);Q.pattern??(Q.pattern=B),A._zod.onattach.push((E)=>{let I=E._zod.bag;I.patterns??(I.patterns=new Set),I.patterns.add(B)}),A._zod.check=(E)=>{if(E.value.startsWith(Q.prefix))return;E.issues.push({origin:"string",code:"invalid_format",format:"starts_with",prefix:Q.prefix,input:E.value,inst:A,continue:!Q.abort})}}),Gd=JA("$ZodCheckEndsWith",(A,Q)=>{PI.init(A,Q);let B=new RegExp(`.*${i8(Q.suffix)}$`);Q.pattern??(Q.pattern=B),A._zod.onattach.push((E)=>{let I=E._zod.bag;I.patterns??(I.patterns=new Set),I.patterns.add(B)}),A._zod.check=(E)=>{if(E.value.endsWith(Q.suffix))return;E.issues.push({origin:"string",code:"invalid_format",format:"ends_with",suffix:Q.suffix,input:E.value,inst:A,continue:!Q.abort})}}),Cd=JA("$ZodCheckOverwrite",(A,Q)=>{PI.init(A,Q),A._zod.check=(B)=>{B.value=Q.tx(B.value)}})});class $O{constructor(A=[],Q={}){this.content=[],this.indent=0,this.args=A,this.closed=Q}indented(A){this.indent+=1,A(this),this.indent-=1}write(A){if(typeof A==="function"){A(this,{execution:"sync"}),A(this,{execution:"async"});return}let B=A.split(`
8
8
  `).filter((D)=>D),E=Math.min(...B.map((D)=>D.length-D.trimStart().length)),I=B.map((D)=>D.slice(E)).map((D)=>" ".repeat(this.indent*2)+D);for(let D of I)this.content.push(D)}compile(){let A=Function,Q=this?.content??[""];return new A(...Object.keys(this.closed),`return function (${this.args.join(", ")}) {
9
9
  ${Q.join(`
10
10
  `)}
@@ -302,7 +302,7 @@ Error message: ${J$(B)}`,cause:B});this[W5A]=!0,this.value=Q,this.context=E}stat
302
302
 
303
303
  `)&&(I===A.length||A.slice(I,I+2)===`
304
304
 
305
- `))return E;E=A.indexOf(Q,E+1)}return-1}function O2A(A){return A instanceof AE&&A.status>=400&&A.status<500&&A.status!==408&&A.status!==425}function L2A(A,Q=[],B={}){let E=A.stream.bind(A),I=A.snapshot.bind(A),D=A.send.bind(A),J=A.respond.bind(A),G=new Map,U=new Set,Y=new Set,H=!1,X=!1,N=!1,z=Promise.resolve(),F=async(v,w)=>{let k=new AbortController,h=w?AbortSignal.any([w,k.signal]):k.signal,t=setTimeout(()=>k.abort(new DOMException("Loading the chat before sending timed out.","TimeoutError")),5000),i,UA=new Promise((CA,GA)=>{if(i=()=>GA(h.reason),h.addEventListener("abort",i,{once:!0}),h.aborted)i()});try{let CA=await Promise.race([I({signal:h}),UA]);v.priorReceipts=new Set(CA.events.flatMap((GA)=>(GA.type==="message.received"||GA.type==="input.resolved")&&GA.meta?.id!==void 0?[GA.meta.id]:[]))}catch(CA){if(h.throwIfAborted(),CA instanceof Error&&(CA.name==="AbortError"||CA.name==="TimeoutError"))throw CA}finally{clearTimeout(t),h.removeEventListener("abort",i)}},V=(v,w)=>{w?.throwIfAborted();let k=z.then(v);if(z=k.then(()=>{return},()=>{return}),!w)return k;return new Promise((h,t)=>{let i=()=>t(w.reason);w.addEventListener("abort",i,{once:!0}),k.then((UA)=>{w.removeEventListener("abort",i),h(UA)},(UA)=>{w.removeEventListener("abort",i),t(UA)})})},O=(v)=>{if(v.type==="turn.started")H=!1,N=!1;else if(v.type==="message.received"&&(v.meta?.id===void 0||!U.has(v.meta.id))){if(v.meta?.id!==void 0)U.add(v.meta.id);H=!1,N=!1;let w=0,k=0,h=0,t=v.data.parts?.map((i)=>i.type==="text"?i.text:null);for(let[i,UA]of G){if(!("message"in UA))continue;if(!UA.dispatched)break;if(v.meta?.id!==void 0&&UA.priorReceipts?.has(v.meta.id))continue;if(t&&UA.parts){let GA=k;if(UA.structured){if(h)GA+=1;let iA;for(;GA<t.length;GA+=1)if(iA=[UA.parts,UA.foldedParts??UA.parts].find((jA)=>jA.length>0&&jA.every((IQ,_A)=>t[GA+_A]===IQ)),iA!==void 0)break;if(iA===void 0)break;k=GA+iA.length,h=0}else{let iA=-1;for(;GA<t.length;GA+=1){let jA=t[GA];if(jA!==null)iA=_2A(jA,UA.message,GA===k?h:0);if(iA!==-1)break}if(iA===-1)break;if(k=GA,h=iA+UA.message.length+2,h>t[GA].length)k+=1,h=0}G.delete(i);continue}let CA=_2A(v.data.message,UA.message,w);if(CA===-1)break;G.delete(i),w=CA+UA.message.length+2}}else if(v.type==="input.resolved"&&(v.meta?.id===void 0||!U.has(v.meta.id))){if(v.meta?.id!==void 0)U.add(v.meta.id);H=!1,N=!1;for(let[w,k]of G){if(!("responses"in k))continue;if(!k.dispatched)continue;if(v.meta?.id!==void 0&&k.priorReceipts?.has(v.meta.id))continue;for(let h of v.data.resolutions)k.responses.delete(h.requestId);if(!k.responses.size)G.delete(w)}}else if(v.type==="authorization.required"&&v.data.webhookUrl!==void 0)Y.add(v.data.name);else if(v.type==="authorization.completed")Y.delete(v.data.name),H=!1;else if(v.type==="session.waiting")H=!0;else if(v.type==="session.completed"||v.type==="session.failed")H=!0,X=!0},j=()=>X||H&&!N&&G.size===0&&Y.size===0;for(let v of Q)O(v);N=B.pendingTurn??!1;let b=async function*(v,w=!1){for await(let k of v)if(O(k),yield k,w&&j()&&(k.type==="session.waiting"||k.type==="session.completed"||k.type==="session.failed"))return},x=(v)=>{let w=v[Symbol.asyncIterator].bind(v);return v[Symbol.asyncIterator]=()=>{let k=w();return b({[Symbol.asyncIterator]:()=>k})},v};return A.send=async(v,w)=>{let k={},h={...aeA(v),dispatched:!1};G.set(k,h);try{return x(await V(async()=>{w?.signal?.throwIfAborted(),await F(h,w?.signal);try{return await D(v,{...w,headers:V2A(h,w?.headers,w?.signal)})}catch(t){if(O2A(t))G.delete(k);throw t}},w?.signal))}catch(t){if(!h.dispatched)G.delete(k);throw t}},A.respond=async(v,w)=>{let k={},h={responses:new Set(v.map((t)=>t.requestId)),dispatched:!1};G.set(k,h);try{return x(await V(async()=>{w?.signal?.throwIfAborted(),await F(h,w?.signal);try{return await J(v,{...w,headers:V2A(h,w?.headers,w?.signal)})}catch(t){if(O2A(t))G.delete(k);throw t}},w?.signal))}catch(t){if(!h.dispatched)G.delete(k);throw t}},A.stream=(v={})=>{let w=v.streamReconnectPolicy!==void 0&&"reconnect"in v.streamReconnectPolicy&&v.streamReconnectPolicy.reconnect===!1;if(v.follow===!1||v.streamReconnectPolicy!==void 0&&!(N&&w))return b(E(v));return b(E({...v,streamReconnectPolicy:j()?{reconnect:!1}:{streamIdleReconnectPolicy:{maxAttempts:Number.POSITIVE_INFINITY}}}),!0)},A}var W2A=W(()=>{wH()});function $M(A){return`${A.host}/api/accounting/agent`}function Gh(A){return{bearer:()=>A.token()}}function Ch(A,Q){return{...p8(),...A.organizationId?{"x-accounting-organization":A.organizationId}:{},...Dh(Q)}}function bH(A,Q){return new TH({host:$M(A),auth:Gh(A),headers:()=>Ch(A,Q()),redirect:"error"})}function kH(A,Q,B,E=0){return L2A(bH(A,Q).sessions.attach(B,{streamIndex:E}))}async function UG(A,Q=fetch){let B=await Q(`${$M(A)}/sessions`,{headers:{...await A.headers(),accept:"application/json"},redirect:"error"}),E=await B.json().catch(()=>null);if(!B.ok)throw new mQ(E?.error?.code??`HTTP_${B.status}`,E?.error?.message??"Couldn't load your recent chats.",B.status);return Array.isArray(E?.data?.chats)?E.data.chats:[]}function Y$(A){if(!(A instanceof AE))return A;let Q;try{Q=JSON.parse(A.body)}catch{Q=null}let B=typeof Q?.code==="string"?Q.code:A.code??`HTTP_${A.status}`,E=typeof Q?.error==="string"?Q.error:typeof Q?.message==="string"?Q.message:`Ask AI answered ${A.status}.`;return new mQ(B,E,A.status)}var j2A=1800000;var PU=W(()=>{wH();l1();W2A();D6();wQ()});var xH;var $h=W(()=>{xH={accounting_accountant_access_get:["accountant.access.get","read"],accounting_accountant_changes_list:["accountant.changes.list","read"],accounting_accountant_changes_request:["accountant.changes.request","write"],accounting_accountant_comments_create:["accountant.comments.create","write"],accounting_accountant_comments_list:["accountant.comments.list","read"],accounting_accountant_requests_create:["accountant.requests.create","write"],accounting_accountant_slips_readiness:["accountant.slips.readiness","read"],accounting_accountant_tax_request:["accountant.tax.request","write"],accounting_accountant_welcome_update:["accountant.welcome.update","write"],accounting_accountants_access_update:["accountants.access.update","access"],accounting_accountants_activity:["accountants.activity","read"],accounting_accountants_comments_list:["accountants.comments.list","read"],accounting_accountants_comments_reply:["accountants.comments.reply","write"],accounting_accountants_comments_resolve:["accountants.comments.resolve","write"],accounting_accountants_grants_revoke:["accountants.grants.revoke","destructive"],accounting_accountants_invitations_link:["accountants.invitations.link","access"],accounting_accountants_invitations_preview:["accountants.invitations.preview","read"],accounting_accountants_invitations_resend:["accountants.invitations.resend","external"],accounting_accountants_invitations_revoke:["accountants.invitations.revoke","destructive"],accounting_accountants_invitations_update:["accountants.invitations.update","access"],accounting_accountants_invite:["accountants.invite","external"],accounting_accountants_invite_many:["accountants.inviteMany","external"],accounting_accountants_list:["accountants.list","read"],accounting_accountants_remove:["accountants.remove","destructive"],accounting_accountants_requests_decide:["accountants.requests.decide","access"],accounting_accounts_create:["accounts.create","write"],accounting_accounts_lifecycle:["accounts.lifecycle","write"],accounting_accounts_lifecycle_preview:["accounts.lifecycle.preview","read"],accounting_accounts_update:["accounts.update","write"],accounting_agents_overview:["agents.overview","read"],accounting_agents_playground_match:["agents.playground.match","read"],accounting_agents_playground_receipt:["agents.playground.receipt","read"],accounting_ai_keys_get:["ai.keys.get","read"],accounting_ai_keys_remove:["ai.keys.remove","write"],accounting_ai_keys_save:["ai.keys.save","write"],accounting_ai_models_list:["ai.models.list","read"],accounting_ai_sandbox_evaluate:["ai.sandbox.evaluate","read"],accounting_ai_settings_get:["ai.settings.get","read"],accounting_ai_settings_update:["ai.settings.update","write"],accounting_api_keys_create:["api_keys.create","access"],accounting_api_keys_list:["api_keys.list","read"],accounting_api_keys_revoke:["api_keys.revoke","destructive"],accounting_api_keys_rotate:["api_keys.rotate","destructive"],accounting_attach_receipt:["entries.attachReceipt","write"],accounting_attention_list:["attention.list","read"],accounting_attention_mine:["attention.mine","read"],accounting_autopilot_classify:["autopilot.classify","write"],accounting_autopilot_explain:["autopilot.explain","read"],accounting_autopilot_jobs_cancel:["autopilot.jobs.cancel","write"],accounting_autopilot_jobs_get:["autopilot.jobs.get","read"],accounting_autopilot_jobs_list:["autopilot.jobs.list","read"],accounting_autopilot_jobs_start:["autopilot.jobs.start","write"],accounting_autopilot_rules_list:["autopilot.rules.list","read"],accounting_autopilot_rules_update:["autopilot.rules.update","write"],accounting_autopilot_settings_get:["autopilot.settings.get","read"],accounting_autopilot_settings_update:["autopilot.settings.update","write"],accounting_autopilot_status:["autopilot.status","read"],accounting_autopilot_summary:["autopilot.summary","read"],accounting_budgets_accounts_designate:["budgets.accounts.designate","write"],accounting_budgets_accounts_get:["budgets.accounts.get","read"],accounting_budgets_evaluate:["budgets.evaluate","write"],accounting_budgets_get:["budgets.get","read"],accounting_budgets_obligations_get:["budgets.obligations.get","read"],accounting_budgets_obligations_save:["budgets.obligations.save","write"],accounting_budgets_overview:["budgets.overview","read"],accounting_budgets_save:["budgets.save","write"],accounting_bulk_categorize:["entries.bulkCategorize","write"],accounting_calendar_events:["calendar.events","read"],accounting_cards_claim:["cards.claim","write"],accounting_cards_claimable:["cards.claimable","read"],accounting_cards_list:["cards.list","read"],accounting_cards_prompt_dismiss:["cards.prompt.dismiss","write"],accounting_cards_save:["cards.save","write"],accounting_cards_set_account_type:["cards.setAccountType","write"],accounting_categories_add_recommended:["categories.addRecommended","write"],accounting_chase_preferences_get:["chase.preferences.get","read"],accounting_chase_preferences_update:["chase.preferences.update","write"],accounting_chase_preview:["chase.preview","read"],accounting_chase_run:["chase.run","external"],accounting_chief_of_staff_channels_update:["chiefOfStaff.channels.update","access"],accounting_chief_of_staff_general_update:["chiefOfStaff.general.update","access"],accounting_chief_of_staff_people_find:["chiefOfStaff.people.find","read"],accounting_chief_of_staff_rules_delete:["chiefOfStaff.rules.delete","access"],accounting_chief_of_staff_rules_save:["chiefOfStaff.rules.save","access"],accounting_chief_of_staff_schedules_update:["chiefOfStaff.schedules.update","access"],accounting_chief_of_staff_servers_list:["chiefOfStaff.servers.list","read"],accounting_chief_of_staff_servers_update:["chiefOfStaff.servers.update","access"],accounting_chief_of_staff_settings_get:["chiefOfStaff.settings.get","read"],accounting_chief_of_staff_status:["chiefOfStaff.status","read"],accounting_classifier_mailboxes_list:["classifier.mailboxes.list","read"],accounting_classifier_mailboxes_save:["classifier.mailboxes.save","write"],accounting_close_period:["reconciliation.close","write"],accounting_commit_bank_import:["imports.commit","write"],accounting_company_apply_record:["company.applyRecord","write"],accounting_company_close:["company.close","destructive"],accounting_company_export:["company.export","write"],accounting_company_export_files:["company.export.files","read"],accounting_company_facts_apply:["company.facts.apply","write"],accounting_company_facts_review:["company.facts.review","read"],accounting_company_get:["company.get","read"],accounting_company_record_changes:["company.recordChanges","read"],accounting_company_shareholders_export:["company.shareholders.export","write"],accounting_company_shareholders_get:["company.shareholders.get","read"],accounting_company_shareholders_tax_number:["company.shareholders.taxNumber","write"],accounting_company_shareholders_update:["company.shareholders.update","write"],accounting_company_update:["company.update","write"],accounting_compliance_checklist:["compliance.checklist","read"],accounting_compliance_items_create:["compliance.items.create","write"],accounting_compliance_items_get:["compliance.items.get","read"],accounting_compliance_items_list:["compliance.items.list","read"],accounting_compliance_items_update:["compliance.items.update","write"],accounting_compliance_kickoff_run:["compliance.kickoff.run","write"],accounting_compliance_library_entries_create:["complianceLibrary.entries.create","write"],accounting_compliance_library_entries_update:["complianceLibrary.entries.update","write"],accounting_compliance_library_files_confirm:["complianceLibrary.files.confirm","write"],accounting_compliance_library_files_prepare:["complianceLibrary.files.prepare","write"],accounting_compliance_library_get:["complianceLibrary.get","read"],accounting_compliance_library_inputs_add_url:["complianceLibrary.inputs.addUrl","write"],accounting_compliance_library_inputs_retry:["complianceLibrary.inputs.retry","write"],accounting_compliance_library_list:["complianceLibrary.list","read"],accounting_compliance_library_proposals_decide:["complianceLibrary.proposals.decide","write"],accounting_compliance_portal_overview:["compliancePortal.overview","read"],accounting_compliance_portal_search:["compliancePortal.search","read"],accounting_compliance_refresh:["compliance.refresh","write"],accounting_compliance_reminders_preview:["compliance.reminders.preview","read"],accounting_compliance_reminders_send_now:["compliance.reminders.sendNow","external"],accounting_compliance_research_chat_ask:["complianceResearch.chat.ask","external"],accounting_compliance_research_chat_history:["complianceResearch.chat.history","read"],accounting_compliance_research_findings_update:["complianceResearch.findings.update","write"],accounting_compliance_research_overview:["complianceResearch.overview","read"],accounting_compliance_research_run:["complianceResearch.run","external"],accounting_compliance_research_settings_update:["complianceResearch.settings.update","write"],accounting_compliance_research_sources_add:["complianceResearch.sources.add","write"],accounting_compliance_research_sources_remove:["complianceResearch.sources.remove","destructive"],accounting_compliance_research_suggestions_decide:["complianceResearch.suggestions.decide","write"],accounting_compliance_research_suggestions_list:["complianceResearch.suggestions.list","read"],accounting_confirm_matching:["matching.confirm","write"],accounting_confirm_upload:["uploads.confirm","write"],accounting_connectors_credentials_remove:["connectors.credentials.remove","destructive"],accounting_connectors_credentials_save:["connectors.credentials.save","write"],accounting_connectors_get:["connectors.get","read"],accounting_connectors_google_drive_connect:["connectors.googleDrive.connect","write"],accounting_connectors_google_drive_status:["connectors.googleDrive.status","read"],accounting_connectors_list:["connectors.list","read"],accounting_connectors_test:["connectors.test","external"],accounting_connectors_update:["connectors.update","write"],accounting_connectors_wise_signing_key_create:["connectors.wise.signingKey.create","write"],accounting_connectors_wise_statement_access:["connectors.wise.statementAccess","read"],accounting_connectors_wise_statements_check:["connectors.wise.statements.check","write"],accounting_contractor_ops_activity_list:["contractorOps.activity.list","read"],accounting_contractor_ops_agreements_add_contractor:["contractorOps.agreements.addContractor","write"],accounting_contractor_ops_agreements_contractor_draft:["contractorOps.agreements.contractorDraft","read"],accounting_contractor_ops_agreements_ended:["contractorOps.agreements.ended","read"],accounting_contractor_ops_agreements_import_executed:["contractorOps.agreements.importExecuted","write"],accounting_contractor_ops_agreements_keep_as_history:["contractorOps.agreements.keepAsHistory","write"],accounting_contractor_ops_agreements_link_contractor:["contractorOps.agreements.linkContractor","write"],accounting_contractor_ops_agreements_list:["contractorOps.agreements.list","read"],accounting_contractor_ops_agreements_send_template:["contractorOps.agreements.sendTemplate","external"],accounting_contractor_ops_agreements_unlinked:["contractorOps.agreements.unlinked","read"],accounting_contractor_ops_directory_list:["contractorOps.directory.list","read"],accounting_contractor_ops_encryption_reset_fingerprint_key:["contractorOps.encryption.resetFingerprintKey","destructive"],accounting_contractor_ops_encryption_status:["contractorOps.encryption.status","read"],accounting_contractor_ops_forms_list:["contractorOps.forms.list","read"],accounting_contractor_ops_forms_save:["contractorOps.forms.save","write"],accounting_contractor_ops_history_allocations_get:["contractorOps.history.allocations.get","read"],accounting_contractor_ops_history_allocations_save:["contractorOps.history.allocations.save","write"],accounting_contractor_ops_history_list:["contractorOps.history.list","read"],accounting_contractor_ops_history_mark_paid:["contractorOps.history.markPaid","access"],accounting_contractor_ops_history_payment_asks_answer:["contractorOps.history.paymentAsks.answer","write"],accounting_contractor_ops_history_payment_asks_list:["contractorOps.history.paymentAsks.list","read"],accounting_contractor_ops_history_rate_backfill_apply:["contractorOps.history.rateBackfill.apply","write"],accounting_contractor_ops_history_rate_backfill_preview:["contractorOps.history.rateBackfill.preview","read"],accounting_contractor_ops_hours_history:["contractorOps.hours.history","read"],accounting_contractor_ops_import_agreements:["contractorOps.import.agreements","write"],accounting_contractor_ops_import_contractors:["contractorOps.import.contractors","write"],accounting_contractor_ops_import_hours:["contractorOps.import.hours","write"],accounting_contractor_ops_import_hours_sync:["contractorOps.import.hoursSync","external"],accounting_contractor_ops_import_hours_sync_status:["contractorOps.import.hoursSyncStatus","read"],accounting_contractor_ops_insights_get:["contractorOps.insights.get","read"],accounting_contractor_ops_payments_reveal:["contractorOps.payments.reveal","write"],accounting_contractor_ops_payments_update:["contractorOps.payments.update","access"],accounting_contractor_ops_payments_verify:["contractorOps.payments.verify","access"],accounting_contractor_ops_payouts_approve:["contractorOps.payouts.approve","access"],accounting_contractor_ops_payouts_cancel:["contractorOps.payouts.cancel","destructive"],accounting_contractor_ops_payouts_get:["contractorOps.payouts.get","read"],accounting_contractor_ops_payouts_list:["contractorOps.payouts.list","read"],accounting_contractor_ops_payouts_mark_paid:["contractorOps.payouts.markPaid","access"],accounting_contractor_ops_payouts_prepare:["contractorOps.payouts.prepare","write"],accounting_contractor_ops_payouts_send:["contractorOps.payouts.send","external"],accounting_contractor_ops_periods_list:["contractorOps.periods.list","read"],accounting_contractor_ops_periods_update:["contractorOps.periods.update","write"],accounting_contractor_ops_profiles_get:["contractorOps.profiles.get","read"],accounting_contractor_ops_profiles_update:["contractorOps.profiles.update","write"],accounting_contractor_ops_reminders_run:["contractorOps.reminders.run","external"],accounting_contractor_ops_roles_archive:["contractorOps.roles.archive","destructive"],accounting_contractor_ops_roles_archive_job:["contractorOps.roles.archiveJob","destructive"],accounting_contractor_ops_roles_assign:["contractorOps.roles.assign","write"],accounting_contractor_ops_roles_duplicate_job:["contractorOps.roles.duplicateJob","write"],accounting_contractor_ops_roles_get:["contractorOps.roles.get","read"],accounting_contractor_ops_roles_import:["contractorOps.roles.import","write"],accounting_contractor_ops_roles_list:["contractorOps.roles.list","read"],accounting_contractor_ops_roles_reorder:["contractorOps.roles.reorder","write"],accounting_contractor_ops_roles_save:["contractorOps.roles.save","write"],accounting_contractor_ops_roles_update_job:["contractorOps.roles.updateJob","write"],accounting_contractor_ops_roles_versions:["contractorOps.roles.versions","read"],accounting_contractor_ops_sales_tax_confirm:["contractorOps.salesTax.confirm","write"],accounting_contractor_ops_settings_get:["contractorOps.settings.get","read"],accounting_contractor_ops_settings_update:["contractorOps.settings.update","write"],accounting_contractor_ops_tax_forms_export:["contractorOps.taxForms.export","write"],accounting_contractor_ops_tax_forms_get:["contractorOps.taxForms.get","read"],accounting_contractor_ops_tax_info_get:["contractorOps.taxInfo.get","read"],accounting_contractor_ops_tax_info_list:["contractorOps.taxInfo.list","read"],accounting_contractor_ops_tax_info_request:["contractorOps.taxInfo.request","write"],accounting_contractor_ops_tax_info_update:["contractorOps.taxInfo.update","write"],accounting_contractor_ops_terms_cancel:["contractorOps.terms.cancel","destructive"],accounting_contractor_ops_terms_confirm:["contractorOps.terms.confirm","write"],accounting_contractor_ops_terms_end_decision:["contractorOps.terms.endDecision","write"],accounting_contractor_ops_terms_get:["contractorOps.terms.get","read"],accounting_contractor_ops_terms_link_role:["contractorOps.terms.linkRole","write"],accounting_contractor_ops_terms_propose:["contractorOps.terms.propose","write"],accounting_contractor_ops_terms_read:["contractorOps.terms.read","write"],accounting_contractor_ops_terms_set:["contractorOps.terms.set","write"],accounting_contractor_ops_timesheets_list:["contractorOps.timesheets.list","read"],accounting_contractor_ops_timesheets_review:["contractorOps.timesheets.review","write"],accounting_contractor_ops_title_change_override:["contractorOps.titleChange.override","write"],accounting_contractor_ops_title_change_plan:["contractorOps.titleChange.plan","read"],accounting_contractor_ops_title_change_propose:["contractorOps.titleChange.propose","write"],accounting_contractor_ops_wise_status:["contractorOps.wise.status","read"],accounting_contractors_access_reset:["contractors.access.reset","destructive"],accounting_contractors_agreements_create:["contractors.agreements.create","write"],accounting_contractors_agreements_download:["contractors.agreements.download","read"],accounting_contractors_agreements_get:["contractors.agreements.get","read"],accounting_contractors_agreements_list:["contractors.agreements.list","read"],accounting_contractors_agreements_remind:["contractors.agreements.remind","external"],accounting_contractors_agreements_revise:["contractors.agreements.revise","write"],accounting_contractors_agreements_send:["contractors.agreements.send","external"],accounting_contractors_agreements_void:["contractors.agreements.void","destructive"],accounting_contractors_create:["contractors.create","write"],accounting_contractors_email_update:["contractors.email.update","write"],accounting_contractors_files_confirm:["contractors.files.confirm","write"],accounting_contractors_files_prepare:["contractors.files.prepare","write"],accounting_contractors_get:["contractors.get","read"],accounting_contractors_hours_list:["contractors.hours.list","read"],accounting_contractors_hours_review:["contractors.hours.review","write"],accounting_contractors_invitations_fix_email:["contractors.invitations.fixEmail","external"],accounting_contractors_invitations_link:["contractors.invitations.link","write"],accounting_contractors_invitations_list:["contractors.invitations.list","read"],accounting_contractors_invitations_revoke:["contractors.invitations.revoke","destructive"],accounting_contractors_invite:["contractors.invite","external"],accounting_contractors_list:["contractors.list","read"],accounting_contractors_notifications_list:["contractors.notifications.list","read"],accounting_contractors_past_payments_link:["contractors.pastPayments.link","write"],accounting_contractors_past_payments_suggest:["contractors.pastPayments.suggest","read"],accounting_contractors_payments_bind:["contractors.payments.bind","write"],accounting_contractors_payments_get:["contractors.payments.get","read"],accounting_contractors_payments_identify:["contractors.payments.identify","write"],accounting_contractors_payments_jobs:["contractors.payments.jobs","read"],accounting_contractors_payments_link:["contractors.payments.link","write"],accounting_contractors_payments_list:["contractors.payments.list","read"],accounting_contractors_payments_unbind:["contractors.payments.unbind","destructive"],accounting_contractors_payments_unlink:["contractors.payments.unlink","destructive"],accounting_contractors_recipients_bind:["contractors.recipients.bind","write"],accounting_contractors_recipients_list:["contractors.recipients.list","read"],accounting_contractors_tax_profile_update:["contractors.taxProfile.update","write"],accounting_contractors_tax_report:["contractors.taxReport","read"],accounting_contractors_templates_create:["contractors.templates.create","write"],accounting_contractors_templates_download:["contractors.templates.download","read"],accounting_contractors_templates_list:["contractors.templates.list","read"],accounting_contractors_templates_preview:["contractors.templates.preview","read"],accounting_contractors_templates_update:["contractors.templates.update","write"],accounting_contractors_update:["contractors.update","write"],accounting_correct_bank_import:["transactions.correct","write"],accounting_create_bank_record:["reconciliation.createEntry","write"],accounting_create_category:["categories.create","write"],accounting_create_record:["entries.create","write"],accounting_data_imports_commit:["dataImports.commit","write"],accounting_data_imports_definitions:["dataImports.definitions","read"],accounting_data_imports_files:["dataImports.files","read"],accounting_data_imports_get:["dataImports.get","read"],accounting_data_imports_history:["dataImports.history","read"],accounting_data_imports_preview:["dataImports.preview","read"],accounting_data_imports_resume:["dataImports.resume","write"],accounting_data_imports_suggest:["dataImports.suggest","read"],accounting_data_imports_undo:["dataImports.undo","destructive"],accounting_data_sources_files:["dataSources.files","read"],accounting_data_sources_import_files:["dataSources.importFiles","write"],accounting_data_sources_list:["dataSources.list","read"],accounting_data_sources_pin:["dataSources.pin","write"],accounting_data_sources_read_text:["dataSources.readText","read"],accounting_data_sources_resolve:["dataSources.resolve","read"],accounting_data_sources_rows:["dataSources.rows","read"],accounting_data_sources_schema:["dataSources.schema","read"],accounting_data_sources_search:["dataSources.search","read"],accounting_developers_requests_list:["developers.requests.list","read"],accounting_developers_usage:["developers.usage","read"],accounting_document_requests_list:["documentRequests.list","read"],accounting_document_requests_recipients:["documentRequests.recipients","read"],accounting_document_requests_revoke:["documentRequests.revoke","destructive"],accounting_document_requests_send:["documentRequests.send","external"],accounting_documents_assets_confirm:["documents.assets.confirm","write"],accounting_documents_assets_list:["documents.assets.list","read"],accounting_documents_assets_prepare:["documents.assets.prepare","write"],accounting_documents_assets_update:["documents.assets.update","write"],accounting_documents_comments_create:["documents.comments.create","write"],accounting_documents_comments_list:["documents.comments.list","read"],accounting_documents_comments_members:["documents.comments.members","read"],accounting_documents_comments_reply:["documents.comments.reply","write"],accounting_documents_comments_resolve:["documents.comments.resolve","write"],accounting_documents_content_edit:["documents.content.edit","write"],accounting_documents_content_get:["documents.content.get","read"],accounting_documents_download:["documents.download","read"],accounting_documents_extract:["documents.extract","write"],accounting_documents_get:["documents.get","read"],accounting_documents_history_get:["documents.history.get","read"],accounting_documents_history_list:["documents.history.list","read"],accounting_documents_history_restore:["documents.history.restore","write"],accounting_documents_list:["documents.list","read"],accounting_documents_records_get:["documents.records.get","read"],accounting_documents_records_search:["documents.records.search","read"],accounting_documents_snippets_create:["documents.snippets.create","write"],accounting_documents_snippets_list:["documents.snippets.list","read"],accounting_documents_snippets_update:["documents.snippets.update","write"],accounting_documents_suggestions_create:["documents.suggestions.create","write"],accounting_documents_suggestions_decide:["documents.suggestions.decide","write"],accounting_documents_suggestions_list:["documents.suggestions.list","read"],accounting_documents_update:["documents.update","write"],accounting_edit_record:["entries.update","write"],accounting_email_domain_activate:["email.domain.activate","external"],accounting_email_domain_configure:["email.domain.configure","external"],accounting_email_domain_status:["email.domain.status","read"],accounting_email_domain_use_platform:["email.domain.usePlatform","write"],accounting_email_domain_verify:["email.domain.verify","external"],accounting_email_outbox_list:["email.outbox.list","read"],accounting_email_status:["email.status","read"],accounting_email_test:["email.test","external"],accounting_entries_context:["entries.context","read"],accounting_entries_delete:["entries.delete","destructive"],accounting_entries_delete_preview:["entries.delete.preview","read"],accounting_entries_deleted_list:["entries.deleted.list","read"],accounting_entries_evidence_confirm:["entries.evidence.confirm","write"],accounting_entries_evidence_prepare:["entries.evidence.prepare","write"],accounting_entries_hold_release_undo:["entries.hold.release.undo","write"],accounting_entries_hold_set:["entries.hold.set","write"],accounting_entries_place_set:["entries.place.set","write"],accounting_entries_restore:["entries.restore","write"],accounting_entries_retry_step:["entries.retryStep","write"],accounting_entries_tags_set:["entries.tags.set","write"],accounting_evidence_inbox_search_cancel:["evidence.inboxSearch.cancel","write"],accounting_evidence_inbox_search_get:["evidence.inboxSearch.get","read"],accounting_evidence_inbox_search_start:["evidence.inboxSearch.start","external"],accounting_exchange_rates_get:["exchangeRates.get","read"],accounting_experiments_get:["experiments.get","read"],accounting_experiments_update:["experiments.update","write"],accounting_export:["reports.export","write"],accounting_get_evidence:["evidence.download","read"],accounting_get_import_evidence:["imports.download","read"],accounting_get_record:["entries.get","read"],accounting_get_submission:["submissions.get","read"],accounting_handoff_export:["handoff.export","read"],accounting_handoff_get:["handoff.get","read"],accounting_handoff_update:["handoff.update","write"],accounting_history_facets:["history.facets","read"],accounting_history_get:["history.get","read"],accounting_history_list:["history.list","read"],accounting_history_rollback_apply:["history.rollback.apply","destructive"],accounting_history_rollback_apply_many:["history.rollback.applyMany","destructive"],accounting_history_rollback_preview:["history.rollback.preview","read"],accounting_history_rollback_preview_many:["history.rollback.previewMany","read"],accounting_identity_get:["identity.get","read"],accounting_imports_undo_apply:["imports.undo.apply","destructive"],accounting_imports_undo_history:["imports.undo.history","read"],accounting_imports_undo_preview:["imports.undo.preview","read"],accounting_imports_undo_restore:["imports.undo.restore","write"],accounting_inbox_address:["inbox.address","read"],accounting_insights_finance_get:["insights.finance.get","read"],accounting_insights_finance_trends:["insights.finance.trends","read"],accounting_insights_forecast_get:["insights.forecast.get","read"],accounting_insights_map_config_get:["insights.map.config.get","read"],accounting_insights_map_drilldown:["insights.map.drilldown","read"],accounting_insights_map_export:["insights.map.export","read"],accounting_insights_map_get:["insights.map.get","read"],accounting_insights_map_view:["insights.map.view","read"],accounting_insights_people_get:["insights.people.get","read"],accounting_insights_projects_get:["insights.projects.get","read"],accounting_insights_tax_get:["insights.tax.get","read"],accounting_intake_classify:["intake.classify","write"],accounting_intake_complete:["intake.complete","write"],accounting_intake_dismiss:["intake.dismiss","destructive"],accounting_intake_from_mail:["intake.fromMail","write"],accounting_intake_get:["intake.get","read"],accounting_intake_inline:["intake.inline","write"],accounting_intake_list:["intake.list","read"],accounting_intake_prepare:["intake.prepare","write"],accounting_intake_process:["intake.process","write"],accounting_intake_read:["intake.read","read"],accounting_investigations_questions_answer:["investigations.questions.answer","write"],accounting_investigations_questions_list:["investigations.questions.list","read"],accounting_investigations_review_run:["investigations.review.run","write"],accounting_investigations_run:["investigations.run","write"],accounting_investigator_accept:["investigator.accept","write"],accounting_investigator_consent_update:["investigator.consent.update","write"],accounting_investigator_dismiss:["investigator.dismiss","write"],accounting_investigator_financial_issue:["investigator.financialIssue","write"],accounting_investigator_for_entry:["investigator.forEntry","read"],accounting_investigator_overview:["investigator.overview","read"],accounting_investigator_run:["investigator.run","write"],accounting_investigator_settings_update:["investigator.settings.update","write"],accounting_invoices_approve:["invoices.approve","write"],accounting_invoices_archive:["invoices.archive","write"],accounting_invoices_automation_run:["invoices.automation.run","write"],accounting_invoices_correct_tax:["invoices.correctTax","write"],accounting_invoices_create:["invoices.create","write"],accounting_invoices_duplicate:["invoices.duplicate","write"],accounting_invoices_files_commit:["invoices.filesCommit","write"],accounting_invoices_files_extract:["invoices.filesExtract","read"],accounting_invoices_files_prepare:["invoices.filesPrepare","write"],accounting_invoices_get:["invoices.get","read"],accounting_invoices_import:["invoices.import","write"],accounting_invoices_issue:["invoices.issue","write"],accounting_invoices_last_for_party:["invoices.lastForParty","read"],accounting_invoices_list:["invoices.list","read"],accounting_invoices_mark_uncollectible:["invoices.markUncollectible","write"],accounting_invoices_numbering_preview:["invoices.numbering.preview","read"],accounting_invoices_pdf:["invoices.pdf","read"],accounting_invoices_plans_create:["invoices.plans.create","write"],accounting_invoices_preview:["invoices.preview","read"],accounting_invoices_project_suggestions:["invoices.projectSuggestions","read"],accounting_invoices_project_totals:["invoices.projectTotals","read"],accounting_invoices_record_payment:["invoices.recordPayment","write"],accounting_invoices_remind:["invoices.remind","external"],accounting_invoices_remove_payment:["invoices.removePayment","destructive"],accounting_invoices_schedule:["invoices.schedule","write"],accounting_invoices_schedules_cancel:["invoices.schedules.cancel","destructive"],accounting_invoices_schedules_create:["invoices.schedules.create","write"],accounting_invoices_schedules_generate:["invoices.schedules.generate","write"],accounting_invoices_schedules_list:["invoices.schedules.list","read"],accounting_invoices_schedules_pause:["invoices.schedules.pause","write"],accounting_invoices_schedules_resume:["invoices.schedules.resume","write"],accounting_invoices_schedules_update:["invoices.schedules.update","write"],accounting_invoices_send:["invoices.send","external"],accounting_invoices_set_project:["invoices.setProject","write"],accounting_invoices_summary:["invoices.summary","read"],accounting_invoices_tax_place:["invoices.taxPlace","read"],accounting_invoices_update:["invoices.update","write"],accounting_invoices_void:["invoices.void","destructive"],accounting_list_accounts:["accounts.list","read"],accounting_list_categories:["categories.list","read"],accounting_list_submissions:["inbox.list","read"],accounting_list_transactions:["transactions.list","read"],accounting_mail_activity_get:["mail.activity.get","read"],accounting_mail_approve:["mail.approve","write"],accounting_mail_ask_admin:["mail.askAdmin","external"],accounting_mail_attach_evidence:["mail.attachEvidence","write"],accounting_mail_download:["mail.download","read"],accounting_mail_drafts_create:["mail.drafts.create","write"],accounting_mail_drafts_update:["mail.drafts.update","write"],accounting_mail_fraud_decide:["mail.fraud.decide","write"],accounting_mail_fraud_rescan:["mail.fraud.rescan","write"],accounting_mail_get:["mail.get","read"],accounting_mail_inbound_addresses:["mail.inboundAddresses","read"],accounting_mail_list:["mail.list","read"],accounting_mail_purchase_candidates:["mail.purchaseCandidates","read"],accounting_mail_rerun:["mail.rerun","write"],accounting_mail_rerun_many:["mail.rerunMany","write"],accounting_mail_retry:["mail.retry","write"],accounting_mail_review_answer:["mail.review.answer","write"],accounting_mail_review_memory:["mail.review.memory","access"],accounting_mail_rules_list:["mail.rules.list","read"],accounting_mail_rules_save:["mail.rules.save","write"],accounting_mail_update:["mail.update","write"],accounting_mailboxes_connect_link:["mailboxes.connect.link","read"],accounting_mailboxes_connect_start:["mailboxes.connect.start","write"],accounting_mailboxes_disconnect:["mailboxes.disconnect","destructive"],accounting_mailboxes_list:["mailboxes.list","read"],accounting_mailboxes_scan:["mailboxes.scan","external"],accounting_mailboxes_update:["mailboxes.update","write"],accounting_match_transaction:["reconciliation.match","write"],accounting_matching_candidates:["matching.candidates","read"],accounting_matching_receipt_consolidation_candidates:["matching.receiptConsolidation.candidates","read"],accounting_matching_receipt_consolidation_confirm:["matching.receiptConsolidation.confirm","write"],accounting_matching_receipt_consolidation_preview:["matching.receiptConsolidation.preview","read"],accounting_matching_receipt_consolidation_undo:["matching.receiptConsolidation.undo","write"],accounting_matching_reject:["matching.reject","write"],accounting_matching_rerun_entry:["matching.rerunEntry","write"],accounting_matching_review:["matching.list","read"],accounting_matching_status:["matching.status","read"],accounting_members_list:["members.list","read"],accounting_members_update:["members.update","destructive"],accounting_memory_list:["memory.list","read"],accounting_memory_save:["memory.save","access"],accounting_merchants_confirm:["merchants.confirm","write"],accounting_merchants_enrich:["merchants.enrich","external"],accounting_merchants_get:["merchants.get","read"],accounting_merchants_list:["merchants.list","read"],accounting_merchants_settings_get:["merchants.settings.get","read"],accounting_merchants_settings_update:["merchants.settings.update","write"],accounting_notifications_checklist_dismiss:["notifications.checklist.dismiss","write"],accounting_notifications_checklist_list:["notifications.checklist.list","read"],accounting_notifications_comments_dismiss:["notifications.comments.dismiss","write"],accounting_notifications_comments_list:["notifications.comments.list","read"],accounting_notifications_joins_dismiss:["notifications.joins.dismiss","write"],accounting_notifications_joins_list:["notifications.joins.list","read"],accounting_notifications_preferences_get:["notifications.preferences.get","read"],accounting_notifications_preferences_update:["notifications.preferences.update","write"],accounting_notion_data_sources_get:["notion.dataSources.get","read"],accounting_notion_data_sources_query:["notion.dataSources.query","read"],accounting_notion_invoices_import:["notion.invoices.import","external"],accounting_notion_invoices_import_preview:["notion.invoices.importPreview","read"],accounting_notion_links_confirm:["notion.links.confirm","external"],accounting_notion_links_create:["notion.links.create","external"],accounting_notion_links_list:["notion.links.list","read"],accounting_notion_links_reject:["notion.links.reject","external"],accounting_notion_links_remove:["notion.links.remove","destructive"],accounting_notion_lookup:["notion.lookup","read"],accounting_notion_resolve_link:["notion.resolveLink","read"],accounting_notion_search:["notion.search","read"],accounting_notion_sync_run:["notion.sync.run","external"],accounting_onboarding_complete:["onboarding.complete","write"],accounting_onboarding_inbox_prompt:["onboarding.inboxPrompt","read"],accounting_onboarding_inbox_prompt_dismiss:["onboarding.inboxPrompt.dismiss","write"],accounting_onboarding_status:["onboarding.status","read"],accounting_parties_archive:["parties.archive","destructive"],accounting_parties_create:["parties.create","write"],accounting_parties_enrich:["parties.enrich","external"],accounting_parties_get:["parties.get","read"],accounting_parties_list:["parties.list","read"],accounting_parties_preview:["parties.preview","read"],accounting_parties_search:["parties.search","read"],accounting_parties_update:["parties.update","write"],accounting_payment_methods_archive:["paymentMethods.archive","destructive"],accounting_payment_methods_list:["paymentMethods.list","read"],accounting_payment_methods_save:["paymentMethods.save","write"],accounting_payment_methods_wise_options:["paymentMethods.wiseOptions","read"],accounting_places_search:["places.search","read"],accounting_places_settings_get:["places.settings.get","read"],accounting_places_settings_update:["places.settings.update","write"],accounting_platform_admin_access_requests_list:["platform.admin.accessRequests.list","read"],accounting_platform_admin_access_requests_review:["platform.admin.accessRequests.review","write"],accounting_platform_admin_experiments_list:["platform.admin.experiments.list","read"],accounting_platform_admin_experiments_update:["platform.admin.experiments.update","write"],accounting_platform_admin_organizations_get:["platform.admin.organizations.get","read"],accounting_platform_admin_organizations_update:["platform.admin.organizations.update","write"],accounting_platform_admin_overview:["platform.admin.overview","read"],accounting_platform_branding_confirm_logo:["platform.branding.confirmLogo","write"],accounting_platform_branding_logo:["platform.branding.logo","read"],accounting_platform_branding_prepare_logo:["platform.branding.prepareLogo","write"],accounting_platform_settings_get:["platform.settings.get","read"],accounting_platform_settings_update:["platform.settings.update","write"],accounting_prepare_upload:["uploads.prepare","write"],accounting_preview_bank_import:["imports.preview","read"],accounting_processing_status:["jobs.get","read"],accounting_proposals_create:["proposals.create","write"],accounting_proposals_decide:["proposals.decide","write"],accounting_proposals_get:["proposals.get","read"],accounting_proposals_list:["proposals.list","read"],accounting_receipt_tax_confirm:["receipt.tax.confirm","write"],accounting_reconciliation:["reconciliation.list","read"],accounting_reconciliation_reopen:["reconciliation.reopen","write"],accounting_recruiting_applications_assign:["recruiting.applications.assign","write"],accounting_recruiting_applications_convert:["recruiting.applications.convert","write"],accounting_recruiting_applications_create:["recruiting.applications.create","write"],accounting_recruiting_applications_get:["recruiting.applications.get","read"],accounting_recruiting_applications_list:["recruiting.applications.list","read"],accounting_recruiting_applications_move:["recruiting.applications.move","write"],accounting_recruiting_applications_reject:["recruiting.applications.reject","write"],accounting_recruiting_applications_restore:["recruiting.applications.restore","write"],accounting_recruiting_applications_resume:["recruiting.applications.resume","read"],accounting_recruiting_applications_summarize:["recruiting.applications.summarize","write"],accounting_recruiting_board_get:["recruiting.board.get","read"],accounting_recruiting_board_save:["recruiting.board.save","write"],accounting_recruiting_interviews_mine:["recruiting.interviews.mine","read"],accounting_recruiting_interviews_save:["recruiting.interviews.save","write"],accounting_recruiting_notes_add:["recruiting.notes.add","write"],accounting_recruiting_postings_get:["recruiting.postings.get","read"],accounting_recruiting_postings_list:["recruiting.postings.list","read"],accounting_recruiting_postings_rotate_link:["recruiting.postings.rotateLink","destructive"],accounting_recruiting_postings_save:["recruiting.postings.save","write"],accounting_recruiting_postings_status:["recruiting.postings.status","write"],accounting_recruiting_scorecards_submit:["recruiting.scorecards.submit","write"],accounting_recruiting_team_list:["recruiting.team.list","read"],accounting_reimbursements_approve:["reimbursements.approve","write"],accounting_reimbursements_bind_recipient:["reimbursements.bindRecipient","write"],accounting_reimbursements_candidates:["reimbursements.candidates","read"],accounting_reimbursements_claim_purchase:["reimbursements.claimPurchase","write"],accounting_reimbursements_complete_payment:["reimbursements.completePayment","write"],accounting_reimbursements_for_entry:["reimbursements.forEntry","read"],accounting_reimbursements_get:["reimbursements.get","read"],accounting_reimbursements_identify:["reimbursements.identify","write"],accounting_reimbursements_link:["reimbursements.link","write"],accounting_reimbursements_list:["reimbursements.list","read"],accounting_reimbursements_match_payment:["reimbursements.matchPayment","write"],accounting_reimbursements_prepare:["reimbursements.prepare","write"],accounting_reimbursements_recipients:["reimbursements.recipients","read"],accounting_reimbursements_record_payment:["reimbursements.recordPayment","write"],accounting_reimbursements_refresh_recipient:["reimbursements.refreshRecipient","write"],accounting_reimbursements_reject:["reimbursements.reject","write"],accounting_reimbursements_send:["reimbursements.send","external"],accounting_reimbursements_submit:["reimbursements.submit","write"],accounting_reimbursements_sync_payment:["reimbursements.syncPayment","external"],accounting_report:["reports.summary","read"],accounting_requests_create:["requests.create","external"],accounting_requests_list:["requests.list","read"],accounting_requests_people:["requests.people","read"],accounting_requests_update:["requests.update","write"],accounting_restore_bank_import:["transactions.restore","write"],accounting_retry_matching:["matching.request","write"],accounting_retry_processing:["submissions.retry","write"],accounting_reverse_bank_import:["transactions.reverse","destructive"],accounting_runs_get:["runs.get","read"],accounting_runs_list:["runs.list","read"],accounting_runs_trace:["runs.trace","read"],accounting_runs_workflows_catalog:["runs.workflows.catalog","read"],accounting_runs_workflows_get:["runs.workflows.get","read"],accounting_runs_workflows_list:["runs.workflows.list","read"],accounting_search_records:["entries.list","read"],accounting_senders_list:["senders.list","read"],accounting_senders_remove:["senders.remove","destructive"],accounting_senders_upsert:["senders.upsert","access"],accounting_settings_get:["settings.get","read"],accounting_settings_rotate_mailbox:["settings.rotateMailbox","destructive"],accounting_settings_update:["settings.update","write"],accounting_signing_envelopes_certificate:["signing.envelopes.certificate","read"],accounting_signing_envelopes_create_draft:["signing.envelopes.createDraft","write"],accounting_signing_envelopes_defaults:["signing.envelopes.defaults","read"],accounting_signing_envelopes_download:["signing.envelopes.download","read"],accounting_signing_envelopes_get:["signing.envelopes.get","read"],accounting_signing_envelopes_import_executed:["signing.envelopes.importExecuted","write"],accounting_signing_envelopes_keep:["signing.envelopes.keep","external"],accounting_signing_envelopes_list:["signing.envelopes.list","read"],accounting_signing_envelopes_prepare:["signing.envelopes.prepare","write"],accounting_signing_envelopes_remind:["signing.envelopes.remind","external"],accounting_signing_envelopes_resend:["signing.envelopes.resend","external"],accounting_signing_envelopes_retry_completion:["signing.envelopes.retryCompletion","write"],accounting_signing_envelopes_revise:["signing.envelopes.revise","destructive"],accounting_signing_envelopes_send:["signing.envelopes.send","external"],accounting_signing_envelopes_sign_as_member:["signing.envelopes.signAsMember","write"],accounting_signing_envelopes_update_draft:["signing.envelopes.updateDraft","write"],accounting_signing_envelopes_void:["signing.envelopes.void","destructive"],accounting_signing_events_list:["signing.events.list","read"],accounting_signing_files_confirm:["signing.files.confirm","write"],accounting_signing_files_from_google_docs:["signing.files.fromGoogleDocs","external"],accounting_signing_files_prepare:["signing.files.prepare","write"],accounting_signing_subjects_search:["signing.subjects.search","read"],accounting_signing_templates_archive:["signing.templates.archive","destructive"],accounting_signing_templates_create:["signing.templates.create","write"],accounting_signing_templates_get:["signing.templates.get","read"],accounting_signing_templates_list:["signing.templates.list","read"],accounting_signing_templates_preview:["signing.templates.preview","read"],accounting_signing_templates_publish:["signing.templates.publish","write"],accounting_signing_templates_update:["signing.templates.update","write"],accounting_split_categories:["reconciliation.split","write"],accounting_statements_download:["statements.download","read"],accounting_statements_lines:["statements.lines","read"],accounting_statements_list:["statements.list","read"],accounting_statements_review:["statements.review","write"],accounting_stripe_accept_change:["stripe.review.acceptChange","write"],accounting_stripe_classify:["stripe.review.resolve","write"],accounting_stripe_confirm_tax:["stripe.tax.confirm","write"],accounting_stripe_match_payout:["stripe.payouts.match","write"],accounting_stripe_payout:["stripe.payouts.get","read"],accounting_stripe_payouts:["stripe.payouts.list","read"],accounting_stripe_report:["stripe.report","read"],accounting_stripe_review:["stripe.review.list","read"],accounting_stripe_snapshot:["stripe.snapshots.download","read"],accounting_stripe_status:["stripe.status","read"],accounting_stripe_sync:["stripe.sync","external"],accounting_stripe_unmatch_payout:["stripe.payouts.unmatch","destructive"],accounting_stripe_year_download:["stripe.year.download","write"],accounting_stripe_year_get:["stripe.year.get","read"],accounting_submission_trip_suggestions:["submissions.tripSuggestions","read"],accounting_submissions_release:["submissions.release","write"],accounting_submit_emails:["emails.submitBatch","write"],accounting_subscriptions_duplicates_check:["subscriptions.duplicates.check","write"],accounting_subscriptions_list:["subscriptions.list","read"],accounting_subscriptions_merges_create:["subscriptions.merges.create","write"],accounting_subscriptions_merges_decide:["subscriptions.merges.decide","write"],accounting_subscriptions_merges_undo:["subscriptions.merges.undo","destructive"],accounting_subscriptions_save:["subscriptions.save","write"],accounting_subscriptions_suggest:["subscriptions.suggest","read"],accounting_summaries_get:["summaries.get","read"],accounting_summaries_update:["summaries.update","write"],accounting_tags_ai_list:["tags.ai.list","read"],accounting_tags_ai_run:["tags.ai.run","write"],accounting_tags_create:["tags.create","write"],accounting_tags_delete:["tags.delete","destructive"],accounting_tags_get:["tags.get","read"],accounting_tags_list:["tags.list","read"],accounting_tags_merge:["tags.merge","write"],accounting_tags_notion_link:["tags.notion.link","external"],accounting_tags_notion_preview:["tags.notion.preview","read"],accounting_tags_notion_resolve:["tags.notion.resolve","external"],accounting_tags_notion_sync:["tags.notion.sync","external"],accounting_tags_notion_unlink:["tags.notion.unlink","external"],accounting_tags_project_update:["tags.project.update","write"],accounting_tags_report:["tags.report","read"],accounting_tags_suggest:["tags.suggest","read"],accounting_tags_update:["tags.update","write"],accounting_tax_adjustments_update:["tax.adjustments.update","write"],accounting_tax_checks_update:["tax.checks.update","write"],accounting_tax_entries_review:["tax.entries.review","write"],accounting_tax_export:["tax.export","write"],accounting_tax_filings_get:["tax.filings.get","read"],accounting_tax_filings_update:["tax.filings.update","write"],accounting_tax_financial_counterparts_clear:["tax.financialCounterparts.clear","write"],accounting_tax_financial_counterparts_get:["tax.financialCounterparts.get","read"],accounting_tax_financial_counterparts_review:["tax.financialCounterparts.review","write"],accounting_tax_gifi_confirm:["tax.gifi.confirm","write"],accounting_tax_gifi_get:["tax.gifi.get","read"],accounting_tax_gifi_update:["tax.gifi.update","write"],accounting_tax_packages_download:["tax.packages.download","write"],accounting_tax_packages_list:["tax.packages.list","read"],accounting_tax_packages_request:["tax.packages.request","external"],accounting_tax_packages_revoke:["tax.packages.revoke","destructive"],accounting_tax_packages_share:["tax.packages.share","external"],accounting_tax_personal_expenses_confirm:["tax.personalExpenses.confirm","write"],accounting_tax_personal_expenses_export:["tax.personalExpenses.export","read"],accounting_tax_personal_expenses_get:["tax.personalExpenses.get","read"],accounting_tax_prep_overview:["tax.prep.overview","read"],accounting_tax_prizes_events_save:["tax.prizes.events.save","write"],accounting_tax_prizes_overview:["tax.prizes.overview","read"],accounting_tax_prizes_payouts_decide:["tax.prizes.payouts.decide","write"],accounting_tax_prizes_recipients_link:["tax.prizes.recipients.link","external"],accounting_tax_prizes_recipients_save:["tax.prizes.recipients.save","external"],accounting_tax_prizes_schedule:["tax.prizes.schedule","write"],accounting_tax_questions_answer:["tax.questions.answer","write"],accounting_tax_questions_list:["tax.questions.list","read"],accounting_tax_readiness:["tax.readiness","read"],accounting_tax_reports_download:["tax.reports.download","write"],accounting_tax_reports_overview:["tax.reports.overview","read"],accounting_tax_requests_add:["tax.requests.add","write"],accounting_tax_requests_extract:["tax.requests.extract","write"],accounting_tax_requests_list:["tax.requests.list","read"],accounting_tax_requests_update:["tax.requests.update","write"],accounting_tax_sources_confirm:["tax.sources.confirm","write"],accounting_tax_sources_prepare:["tax.sources.prepare","write"],accounting_tax_statements_acknowledge:["tax.statements.acknowledge","write"],accounting_tax_statements_overview:["tax.statements.overview","read"],accounting_tax_statements_pack:["tax.statements.pack","write"],accounting_tax_treatment_apply:["tax.treatment.apply","write"],accounting_tax_treatment_auto:["tax.treatment.auto","write"],accounting_tax_treatment_undo:["tax.treatment.undo","write"],accounting_team_invitations_link:["team.invitations.link","access"],accounting_team_invitations_resend:["team.invitations.resend","external"],accounting_team_invitations_revoke:["team.invitations.revoke","destructive"],accounting_team_invite:["team.invite","external"],accounting_team_list:["team.list","read"],accounting_team_members_remove:["team.members.remove","destructive"],accounting_transactions_documents_download:["transactions.documents.download","read"],accounting_transactions_get:["transactions.get","read"],accounting_trips_create:["trips.create","write"],accounting_trips_get:["trips.get","read"],accounting_trips_link_entry:["trips.linkEntry","write"],accounting_trips_list:["trips.list","read"],accounting_trips_unlink_entry:["trips.unlinkEntry","write"],accounting_trips_update:["trips.update","write"],accounting_unmatch_transaction:["reconciliation.unmatch","destructive"],accounting_update_category:["categories.update","write"],accounting_uploads_inline:["uploads.inline","write"],accounting_webhooks_deliveries_list:["webhooks.deliveries.list","read"],accounting_webhooks_deliveries_retry:["webhooks.deliveries.retry","external"],accounting_webhooks_deliveries_stats:["webhooks.deliveries.stats","read"],accounting_webhooks_endpoints_archive:["webhooks.endpoints.archive","destructive"],accounting_webhooks_endpoints_create:["webhooks.endpoints.create","access"],accounting_webhooks_endpoints_list:["webhooks.endpoints.list","read"],accounting_webhooks_endpoints_rotate_secret:["webhooks.endpoints.rotateSecret","destructive"],accounting_webhooks_endpoints_update:["webhooks.endpoints.update","write"],accounting_webhooks_events_catalog:["webhooks.events.catalog","read"],accounting_webhooks_test:["webhooks.test","external"],accounting_wise_profiles:["wise.profiles","read"],accounting_wise_receipts_decide:["wise.receipts.decide","write"],accounting_wise_receipts_review:["wise.receipts.review","read"],accounting_wise_receipts_status:["wise.receipts.status","read"],accounting_wise_receipts_sync:["wise.receipts.sync","external"],accounting_wise_status:["wise.status","read"],accounting_wise_sync:["wise.sync","external"]}});function R2A(A){let Q=Object.hasOwn(xH,A)?xH[A]:void 0;return Q?{action:Q[0],kind:Q[1]}:null}var g2A=W(()=>{$h()});var T2A=()=>{};function S2A(A){return Object.hasOwn(P2A,A)}function Uh(A,Q){let B=P2A[A],E=A.replace(/^accounting_/,"").replaceAll("_"," "),I=B?.[0]??`Running ${E}`,D=B?.[1]??`Ran ${E}`;if(Q==="output-error")return`Couldn't finish: ${I.charAt(0).toLowerCase()}${I.slice(1)}`;if(Q==="output-denied")return`Skipped: ${I.charAt(0).toLowerCase()}${I.slice(1)}`;return Q==="output-available"?D:`${I}…`}function UM(A){for(let Q=A.length-1;Q>=0;Q-=1){let B=A[Q].parts;for(let E=B.length-1;E>=0;E-=1){let I=B[E];if(I.type!=="dynamic-tool"||I.state!=="approval-requested")continue;let D=I.toolMetadata?.eve?.inputRequest;if(D)return{request:D,toolCallId:I.toolCallId}}}return null}function w2A(A){return A.toolName==="ask_question"||A.toolMetadata?.eve?.inputRequest!==void 0}function YM(A){let Q=A.options??[];if(A.allowFreeform===!1)return Q;return Q.filter((B)=>!oeA.test(B.label.trim()))}var P2A,oeA;var K$=W(()=>{P2A={accounting_get_record:["Reading the transaction","Read the transaction"],accounting_search_records:["Searching transactions","Searched transactions"],accounting_entries_context:["Checking the trip and place","Checked the trip and place"],accounting_autopilot_explain:["Reading the history","Read the history"],accounting_summaries_get:["Reading the purchase summary","Read the purchase summary"],accounting_investigator_for_entry:["Checking the investigation","Checked the investigation"],accounting_investigations_questions_list:["Checking open questions","Checked open questions"],accounting_matching_candidates:["Looking for matches","Looked for matches"],accounting_transactions_get:["Reading the bank line","Read the bank line"],accounting_list_transactions:["Searching bank lines","Searched bank lines"],accounting_list_categories:["Checking categories","Checked categories"],accounting_list_accounts:["Checking accounts","Checked accounts"],accounting_tags_list:["Checking projects","Checked projects"],accounting_tags_suggest:["Suggesting projects","Suggested projects"],accounting_merchants_get:["Reading the vendor","Read the vendor"],accounting_merchants_list:["Searching vendors","Searched vendors"],accounting_parties_search:["Searching customers and vendors","Searched customers and vendors"],accounting_contractors_list:["Searching contractors","Searched contractors"],accounting_contractors_payments_get:["Checking the contractor payment","Checked the contractor payment"],accounting_trips_list:["Checking trips","Checked trips"],accounting_trips_get:["Reading the trip","Read the trip"],accounting_reimbursements_for_entry:["Checking the reimbursement","Checked the reimbursement"],accounting_mail_get:["Reading the email","Read the email"],accounting_mail_list:["Searching email","Searched email"],accounting_mail_activity_get:["Reading the email's history","Read the email's history"],accounting_mail_purchase_candidates:["Looking for the purchase","Looked for the purchase"],accounting_get_submission:["Reading the receipt upload","Read the receipt upload"],accounting_list_submissions:["Searching receipts","Searched receipts"],accounting_memory_list:["Checking what Oatmilk remembers","Checked what Oatmilk remembers"],accounting_edit_record:["Updating the transaction","Updated the transaction"],accounting_entries_tags_set:["Updating projects","Updated projects"],accounting_entries_hold_set:["Marking the hold","Marked the hold"],accounting_attach_receipt:["Attaching the receipt","Attached the receipt"],accounting_match_transaction:["Matching the bank line","Matched the bank line"],accounting_split_categories:["Splitting categories","Split categories"],accounting_receipt_tax_confirm:["Confirming the tax","Confirmed the tax"],accounting_autopilot_classify:["Asking Autopilot","Asked Autopilot"],accounting_create_category:["Creating a category","Created a category"],accounting_tags_create:["Creating a project","Created a project"],accounting_trips_create:["Creating a trip","Created a trip"],accounting_trips_link_entry:["Adding it to the trip","Added it to the trip"],accounting_reimbursements_submit:["Submitting the reimbursement","Submitted the reimbursement"],accounting_contractors_payments_link:["Linking the contractor","Linked the contractor"],accounting_merchants_confirm:["Updating the vendor","Updated the vendor"],accounting_investigations_questions_answer:["Answering the question","Answered the question"],accounting_mail_update:["Updating the email","Updated the email"],accounting_mail_attach_evidence:["Attaching the email","Attached the email"],accounting_mail_drafts_create:["Drafting it for the books","Drafted it for the books"],accounting_mail_drafts_update:["Fixing the draft","Fixed the draft"],accounting_mail_approve:["Adding it to the books","Added it to the books"],accounting_mail_review_answer:["Answering Oatmilk's question","Answered Oatmilk's question"],accounting_mail_retry:["Processing the email again","Processing the email again"],accounting_intake_from_mail:["Filing the attachment","Filed the attachment"],accounting_retry_processing:["Reading the receipt again","Reading the receipt again"],accounting_memory_save:["Remembering this","Remembered this"],get_item:["Reading the latest details","Read the latest details"],read_attachment:["Reading the file","Read the file"]};oeA=/^(other|something else|none of these|not sure|something different)\b/i});var v2A=()=>{};var avQ;var yH=W(()=>{v2A();avQ=Object.freeze({data:void 0,hasData:!1,at:0,fetching:!1,error:void 0})});var Yh=()=>{};function y2A(A,Q){if(S2A(A))return Uh(A,Q);let B=eeA[A];if(B){if(Q==="output-error")return`Couldn't finish: ${B[0].charAt(0).toLowerCase()}${B[0].slice(1)}`;if(Q==="output-denied")return`Not done: ${B[0].charAt(0).toLowerCase()}${B[0].slice(1)}`;return Q==="output-available"?B[1]:`${B[0]}…`}let E=A.split("_").filter((U)=>U&&!teA.has(U)),I=-1;for(let U=E.length-1;U>=0&&I<0;U-=1)if(E[U]in b2A)I=U;let D=I>=0?E[I]:"run",J=E.filter((U,Y)=>Y!==I).join(" ")||"the tool",G=`${b2A[D]} ${J}`;if(Q==="output-error")return`Couldn't finish: ${G.charAt(0).toLowerCase()}${G.slice(1)}`;if(Q==="output-denied")return`Not done: ${G.charAt(0).toLowerCase()}${G.slice(1)}`;return Q==="output-available"?`${x2A[D]} ${J}`:`${G}…`}function QAQ(A){let Q=A.toolName==="attachments"?A.input?.action:void 0,B=AAQ[A.toolName==="attachments"?`attachments:${typeof Q==="string"?Q:"open"}`:A.toolName];if(!B)return;if(A.state==="output-error"||A.state==="output-available"&&Boolean(A.output?.error))return`Couldn't finish: ${B[0].charAt(0).toLowerCase()}${B[0].slice(1)}`;if(A.state==="output-denied")return`Not done: ${B[0].charAt(0).toLowerCase()}${B[0].slice(1)}`;return A.state==="output-available"?B[1]:`${B[0]}…`}function YG(A){if(A.toolName===_4)return A.state==="output-available"||A.state==="output-denied"?null:"Looking that up…";if(A.toolName===M2A){let E=A.input?.action==="read";if(A.state==="output-error")return"Couldn't read the developer docs";if(A.state==="output-available"||A.state==="output-denied")return E?"Read the developer docs":null;return E?"Reading the developer docs…":"Searching the developer docs…"}if(A.toolName===Jh){let E=A.input,I=A.state==="output-available"?$G(A.output):null;if(E?.action!=="open")return A.state==="output-available"?null:"Finding the page…";if(I)return I.open==="now"?`Opened ${I.label}`:null;if(A.state==="output-error")return"Couldn't open that page";return`Opening ${typeof E.label==="string"?E.label:"the page"}…`}let Q=QAQ(A);if(Q!==void 0)return Q;let B=CM(A.toolName,A.input);if(B)return y2A(B.name,A.state);return Uh(A.toolName,A.state)}function BAQ(A){if(A.endsWith("ies"))return`${A.slice(0,-3)}y`;if(/(ses|xes|ches|shes)$/.test(A))return A.slice(0,-2);return A.endsWith("s")&&!A.endsWith("ss")?A.slice(0,-1):A}function O8(A,Q){let B=CM(A.toolName,A.input);if(!B)return Q;let E=y2A(B.name,"output-available"),I=E.split(" ")[0],D=Object.entries(x2A).find(([,X])=>X===I)?.[0],J=E.slice(I.length+1),G=J.split(" "),U=typeof B.input.id==="string"&&G.length>0?`this ${[...G.slice(0,-1),BAQ(G.at(-1))].join(" ")}`:J,Y=D?`${D} ${U}`:E,H=["name","title","subject","displayName","merchant","label"].map((X)=>B.input[X]).find((X)=>typeof X==="string"&&X.trim().length>0);return`Allow Oatmilk to ${Y}${H?` (${H.trim().slice(0,60)})`:""}?`}function IAQ(A){return A&&typeof A==="object"&&!Array.isArray(A)?A:null}function f2A(A,Q){for(let B=A.length-1;B>=0;B-=1){let E=A[B];if(E.type!=="actions.requested")continue;let I=E.data.actions.find((D)=>D.kind==="tool-call"&&D.callId===Q);if(I&&I.kind==="tool-call")return{toolName:I.toolName,input:I.input}}return null}function h2A(A,Q){if(A.type!=="action.result"||A.data.status!=="completed")return null;let B=A.data.result;if(B.kind!=="tool-result"||B.isError===!0)return null;let E=f2A(Q,B.callId),I=E?CM(E.toolName,E.input):null,D=I?R2A(I.name):null;if(!I||!D||D.kind==="read")return null;return{tool:I.name,action:D.action,input:I.input}}function u2A(A,Q){if(A.type!=="action.result"||A.data.status!=="completed")return null;let B=A.data.result;if(B.kind!=="tool-result"||B.isError===!0)return null;let E=f2A(Q,B.callId);if(E?.toolName!==Jh||IAQ(E.input)?.action!=="open")return null;return $G(B.output)}function EAQ(A,Q){if(Q?.get("invoice")||/\/finance\/invoices\/[^/]+\/edit$/.test(A))return["Summarize this invoice","Which project is this for?","Has this customer paid on time before?"];if(Q?.get("party")||Q?.get("account"))return["What does this customer owe us?","How fast do they usually pay?","Look this customer up online"];if(A==="/finance/invoices/new")return["Draft an invoice like the last one","Who did we invoice last month?","Which payment terms do we usually use?"];let B=Q?.get("view");if(B==="customers"||B==="vendors"||B==="accounts"||B==="archived-accounts")return["Who owes us the most?","Which customers pay late?","Look up our newest customer online"];if(B==="scheduled")return["What goes out this week?","Which recurring invoices need approval?","Pause a recurring invoice"];let E=Q?.get("status");if(E==="needs_action")return["What needs me first?","Approve what's ready to go","Remind customers who are late"];if(E==="overdue"||E==="open")return["Who owes us the most?","Draft reminders for late invoices","How much is overdue by currency?"];if(E==="archived")return["Find an archived invoice","Restore an invoice","Which archived invoices were paid?"];return["Which invoices are overdue?","Tie invoices to projects","Who owes us the most?"]}function DAQ(A){let Q=A?.get("view");if(Q==="records")return["Which tax papers do we keep?","Find last year's tax return","What is this page for?"];if(Q==="workpaper")return["Explain this workpaper","Which records still need a look?",LD];let B=A?.get("step")??"",E=Object.hasOwn(k2A,B)?k2A[B]:null;if(E)return[Kh,...E];return A?.get("kind")==="gst_hst"?[LD,Kh,_8]:[LD,"What does my accountant still need?",Kh]}function JAQ(A,Q){if(Q?.get("item"))return["What do I need to do this?","Mark this done","Who should own this?"];if(A.startsWith("/calendar"))return["What's due this month?","What's coming up next month?","Which deadlines are overdue?"];return["What should I do first?","What's due in the next 30 days?","Assign the overdue items to me"]}function KM(A,Q,B){if(Q==="accountant"){if(A==="/accountant/map")return["Find transactions on this map","What's in this area?","Download this map as an image"];if(A.startsWith("/accountant/access"))return["What access do I have?","When does my access end?","How do I ask for more access?"];if(A.startsWith("/accountant/transactions")||A.startsWith("/accountant/receipts"))return["Explain this record","Find a transaction","Which receipts are missing?"];if(A.startsWith("/accountant/financial-statements"))return["Explain the income statement","Why doesn't the trial balance balance?","Download the balance sheet"];if(A.startsWith("/accountant/reports"))return["Make the year-end package","Summarize Stripe for the year","Which records need review?"];return["What is missing for year-end?","Find a transaction","What can you help me with?"]}if(A.startsWith("/developers"))return[Q==="admin"?"How do I verify webhook signatures?":"How do I make my first API request?","Why did my last API request fail?","Which permissions does my script need?"];if(Q==="contributor")return["Which of my purchases need a receipt?","Help me get paid back for something","What can I do here?"];if(A.startsWith("/finance/transactions")||A.startsWith("/finance/reconcile"))return["What needs me here?","Categorize the ones Autopilot is unsure about","Find a transaction"];if(A.startsWith("/finance/financial-statements"))return["Send everything to my accountant","Explain the income statement","Download the balance sheet for last quarter"];if(A.startsWith("/inbox")&&B?.get("view")==="ai")return Q==="admin"?["Read our email with GLM 5.3 Flash at high effort","Which models read our email?","Put the inbox back on the recommended models"]:["Which models read our email?","What does effort change?","What does the second opinion do?"];if(A.startsWith("/inbox"))return["What came in that needs me?","Which emails are quarantined and why?","Find a receipt"];if(A.startsWith("/finance/invoices"))return EAQ(A,B);if(A==="/finance/tax")return DAQ(B);if(A.startsWith("/finance/tax"))return["Which company details does tax need?",LD,"What can you do here?"];if(A.startsWith("/checklist")||A.startsWith("/calendar"))return JAQ(A,B);if(A.startsWith("/people/contractors"))return["Whose timesheets need review?","Who's due a payout?","Find a contractor"];if(A.startsWith("/legal"))return["Which agreements are waiting on signatures?","Find an agreement","Send an agreement for signature"];if(A==="/insights"&&B?.get("view")==="map")return["Show our trips on this map","What's in this area?","Download this map as an image"];if(A.startsWith("/insights")||A.startsWith("/finance/reports"))return["How did we spend last month?","What changed since last quarter?","Explain this page"];if(A.startsWith("/settings"))return["Who has access to this company?","How do receipts get into Oatmilk?","Take me to bank connections"];return["What needs me today?","Take me to receipt matching","What can you do here?"]}var b2A,x2A,teA,eeA,AAQ,Kh="What does this step mean?",LD="What's left before I can file?",_8="Do this step with me",k2A;var L8=W(()=>{l1();g2A();T2A();K$();yH();Yh();b2A={list:"Listing",get:"Reading",search:"Searching",create:"Creating",update:"Updating",set:"Setting",delete:"Deleting",remove:"Removing",send:"Sending",link:"Linking",unlink:"Unlinking",approve:"Approving",archive:"Archiving",match:"Matching",start:"Starting",run:"Running",answer:"Answering",submit:"Submitting",save:"Saving",review:"Reviewing",retry:"Retrying",void:"Voiding",invite:"Inviting",import:"Importing",export:"Exporting",confirm:"Confirming",classify:"Classifying",explain:"Explaining",status:"Checking",overview:"Checking",report:"Reporting on",revoke:"Revoking",restore:"Restoring",prepare:"Preparing",remind:"Reminding",resend:"Resending",decide:"Deciding on",split:"Splitting",unmatch:"Unmatching",reopen:"Reopening",close:"Closing",download:"Getting",preview:"Previewing",commit:"Importing",suggest:"Suggesting",candidates:"Finding"},x2A={list:"Listed",get:"Read",search:"Searched",create:"Created",update:"Updated",set:"Set",delete:"Deleted",remove:"Removed",send:"Sent",link:"Linked",unlink:"Unlinked",approve:"Approved",archive:"Archived",match:"Matched",start:"Started",run:"Ran",answer:"Answered",submit:"Submitted",save:"Saved",review:"Reviewed",retry:"Retried",void:"Voided",invite:"Invited",import:"Imported",export:"Exported",confirm:"Confirmed",classify:"Classified",explain:"Explained",status:"Checked",overview:"Checked",report:"Reported on",revoke:"Revoked",restore:"Restored",prepare:"Prepared",remind:"Reminded",resend:"Resent",decide:"Decided on",split:"Split",unmatch:"Unmatched",reopen:"Reopened",close:"Closed",download:"Got",preview:"Previewed",commit:"Imported",suggest:"Suggested",candidates:"Found"},teA=new Set(["accounting","ops","v1"]),eeA={accounting_bulk_categorize:["Categorizing transactions","Categorized transactions"],accounting_attention_list:["Checking what needs you","Checked what needs you"],accounting_attention_mine:["Checking your purchases","Checked your purchases"],accounting_autopilot_status:["Checking Autopilot","Checked Autopilot"],accounting_report:["Adding up the totals","Added up the totals"],accounting_insights_finance_get:["Reading finance insights","Read finance insights"],accounting_insights_finance_trends:["Reading spending trends","Read spending trends"],accounting_insights_people_get:["Reading people insights","Read people insights"],accounting_insights_projects_get:["Reading project insights","Read project insights"],accounting_insights_tax_get:["Reading tax insights","Read tax insights"],accounting_tax_prep_overview:["Checking your tax steps","Checked your tax steps"],accounting_tax_readiness:["Checking the tax workpaper","Checked the tax workpaper"],accounting_tax_financial_counterparts_get:["Reading the transfer review","Read the transfer review"],accounting_tax_financial_counterparts_review:["Saving the transfer review","Saved the transfer review"],accounting_tax_financial_counterparts_clear:["Removing the transfer review","Removed the transfer review"],accounting_matching_receipt_consolidation_candidates:["Finding saved payments for the receipt","Found saved payments for the receipt"],accounting_matching_receipt_consolidation_preview:["Checking the receipt against the saved payment","Checked the receipt against the saved payment"],accounting_matching_receipt_consolidation_confirm:["Linking the receipt to the saved payment","Linked the receipt to the saved payment"],accounting_matching_receipt_consolidation_undo:["Undoing the receipt link","Undid the receipt link"],accounting_investigator_financial_issue:["Investigating the financial issue","Investigated the financial issue"],accounting_tax_sources_prepare:["Getting ready to add a tax paper","Got ready to add a tax paper"],accounting_tax_sources_confirm:["Saving the tax paper","Saved the tax paper"],accounting_tax_entries_review:["Saving the sales tax check","Saved the sales tax check"],accounting_tax_treatment_auto:["Sorting the sales tax","Sorted the sales tax"],accounting_tax_treatment_apply:["Confirming the sales tax for a group","Confirmed the sales tax for a group"],accounting_tax_treatment_undo:["Undoing a sales tax choice","Undid a sales tax choice"],accounting_tax_adjustments_update:["Saving your GST/HST adjustments","Saved your GST/HST adjustments"],accounting_tax_checks_update:["Saving your answer","Saved your answer"],accounting_tax_export:["Making the year-end package","Made the year-end package"],accounting_tax_gifi_get:["Reading your tax form lines","Read your tax form lines"],accounting_tax_gifi_update:["Matching categories to the tax form","Matched categories to the tax form"],accounting_tax_gifi_confirm:["Confirming the tax form lines","Confirmed the tax form lines"],accounting_tax_questions_list:["Reading the year-end questions","Read the year-end questions"],accounting_tax_questions_answer:["Saving your answer","Saved your answer"],accounting_tax_requests_list:["Checking your accountant's list","Checked your accountant's list"],accounting_tax_requests_extract:["Reading your accountant's email","Read your accountant's email"],accounting_tax_requests_add:["Adding to your accountant's list","Added to your accountant's list"],accounting_tax_requests_update:["Updating your accountant's list","Updated your accountant's list"],accounting_tax_statements_overview:["Checking your statements","Checked your statements"],accounting_tax_statements_pack:["Packing your statements","Packed your statements"],accounting_tax_statements_acknowledge:["Noting a statement gap for your accountant","Noted a statement gap for your accountant"],accounting_tax_personal_expenses_get:["Checking costs paid personally","Checked costs paid personally"],accounting_tax_personal_expenses_confirm:["Saving your answer about personal costs","Saved your answer about personal costs"],accounting_tax_personal_expenses_export:["Making the personal costs list","Made the personal costs list"],accounting_tax_prizes_overview:["Checking prize payouts","Checked prize payouts"],accounting_tax_prizes_events_save:["Saving the prize event","Saved the prize event"],accounting_tax_prizes_payouts_decide:["Saving the prize payout","Saved the prize payout"],accounting_tax_prizes_recipients_save:["Saving the winner","Saved the winner"],accounting_tax_prizes_recipients_link:["Updating the winner's link","Updated the winner's link"],accounting_tax_prizes_schedule:["Making the T4A list","Made the T4A list"],accounting_tax_reports_overview:["Reading the reports for your accountant","Read the reports for your accountant"],accounting_tax_reports_download:["Making the report for your accountant","Made the report for your accountant"],accounting_stripe_year_get:["Reading Stripe for the year","Read Stripe for the year"],accounting_stripe_year_download:["Making the Stripe download for the year","Made the Stripe download for the year"],accounting_tax_filings_get:["Checking what's left to file","Checked what's left to file"],accounting_tax_filings_update:["Recording what you filed","Recorded what you filed"],accounting_company_get:["Reading your company details","Read your company details"],accounting_company_update:["Updating your company details","Updated your company details"],accounting_tax_packages_list:["Checking the year-end packages","Checked the year-end packages"],accounting_tax_packages_request:["Putting everything in one ZIP","Started putting everything in one ZIP"],accounting_tax_packages_share:["Sending the package","Sent the package"],accounting_tax_packages_revoke:["Turning off the package links","Turned off the package links"],accounting_tax_packages_download:["Getting the package download","Got the package download"],accounting_company_shareholders_get:["Reading the shareholder register","Read the shareholder register"],accounting_company_shareholders_update:["Updating the shareholder register","Updated the shareholder register"],accounting_company_shareholders_tax_number:["Saving a shareholder's tax number","Saved a shareholder's tax number"],accounting_company_shareholders_export:["Making the register with tax numbers","Made the register with tax numbers"],accounting_company_facts_review:["Reading what your documents say about the company","Read what your documents say about the company"],accounting_company_facts_apply:["Saving company details from your documents","Saved company details from your documents"],accounting_handoff_get:["Reading the accountant hand-off","Read the accountant hand-off"],accounting_handoff_update:["Saving the accountant hand-off","Saved the accountant hand-off"],accounting_handoff_export:["Making the accountant package","Made the accountant package"],accounting_accountants_invite:["Inviting your accountant","Invited your accountant"],accounting_close_period:["Locking an account's records","Locked an account's records"],accounting_contractor_ops_directory_list:["Listing contractors","Listed contractors"],accounting_documents_content_get:["Reading the document","Read the document"],accounting_documents_content_edit:["Editing the document","Edited the document"],accounting_signing_templates_publish:["Publishing the template","Published the template"],accounting_list_submissions:["Searching receipts","Searched receipts"],accounting_intake_get:["Checking your file","Checked your file"],accounting_intake_read:["Reading your file","Read your file"],accounting_intake_classify:["Working out what your file is","Worked out what your file is"],accounting_intake_process:["Putting your file where it goes","Put your file where it goes"]};AAQ={"attachments:open":["Opening your files","Opened your files"],"attachments:view":["Looking at your file","Looked at your file"],"attachments:add":["Adding your file to Oatmilk","Added your file to Oatmilk"],bash:["Working with your files","Worked with your files"],read_file:["Reading a file","Read a file"],write_file:["Writing a file","Wrote a file"]};k2A={accountant:["What does my accountant still need?","Turn their email into a to-do list"],company:["Which details are missing?",_8],bank:["Which bank records are missing?",_8],statements:["Which statements are missing?",_8],review:["Which records need a look?",_8],records:["Which records need a look?",_8],tax_records:["Which records need a sales tax check?",_8],close:["Is it safe to lock the records?",LD],questions:["Answer the questions with me",LD],personal:["Did anyone pay with their own money?",_8],prizes:["Which winners need a T4A slip?",_8],gifi:["Match the categories with me",LD],handoff:["Make the year-end package","Write a note to my accountant"],adjustments:[_8,LD],return:["Explain these GST/HST numbers",LD]}});function GAQ(A){return m2A.test(A)}function fH(A){let Q=m2A.exec(A);if(!Q)throw Error(`Expected a six-digit hex color such as #1a2b3c, got "${A}"`);let B=Q[1];return[parseInt(B.slice(0,2),16),parseInt(B.slice(2,4),16),parseInt(B.slice(4,6),16)]}function hH(A){return`#${A.map((Q)=>Math.round(Math.min(255,Math.max(0,Q))).toString(16).padStart(2,"0")).join("")}`}function XQ(A,Q,B){let E=fH(A),I=fH(Q);return hH([E[0]+(I[0]-E[0])*B,E[1]+(I[1]-E[1])*B,E[2]+(I[2]-E[2])*B])}function Hh(A){let Q=A/255;return Q<=0.04045?Q/12.92:((Q+0.055)/1.055)**2.4}function H$(A){let[Q,B,E]=fH(A);return 0.2126*Hh(Q)+0.7152*Hh(B)+0.0722*Hh(E)}function rE(A,Q){let[B,E]=[H$(A),H$(Q)].sort((I,D)=>D-I);return(B+0.05)/(E+0.05)}function c2A(A,Q){return Q.reduce((B,E)=>rE(E,A)>rE(B,A)?E:B)}function W8(A,Q,B,E){for(let I=0;I<=40;I+=1){let D=XQ(A,E,I/40);if(Q.every((J)=>rE(D,J)>=B))return D}return E}function Xh(A){let Q=fH(A),B=Math.max(...Q);if(B===0)return"#ffffff";return hH([Q[0]*255/B,Q[1]*255/B,Q[2]*255/B])}function wU(A,Q,B,E=4.5){let I=(D)=>Q.every((J)=>rE(D,J)>=E);if(I(A))return A;if(H$(B)>0.5){let D=W8(A,Q,E,Xh(A));if(I(D))return D;return W8(D,Q,E,B)}return W8(A,Q,E,B)}function l2A(A,Q){let[B,E,I]=fH(A);return`rgb(${B} ${E} ${I} / ${Math.round(Q*100)}%)`}function CAQ(A,Q,B){let E=Q*Math.cos(B*Math.PI/180),I=Q*Math.sin(B*Math.PI/180),D=(A+0.3963377774*E+0.2158037573*I)**3,J=(A-0.1055613458*E-0.0638541728*I)**3,G=(A-0.0894841775*E-1.291485548*I)**3,U=[4.0767416621*D-3.3077115913*J+0.2309699292*G,-1.2684380046*D+2.6097574011*J-0.3413193965*G,-0.0041960863*D-0.7034186147*J+1.707614701*G],Y=(H)=>{let X=Math.min(1,Math.max(0,H));return 255*(X<=0.0031308?12.92*X:1.055*X**0.4166666666666667-0.055)};return hH([Y(U[0]),Y(U[1]),Y(U[2])])}function $AQ(A,Q,B){let E=(1-Math.abs(2*B-1))*Q,I=(A%360+360)%360/60,D=E*(1-Math.abs(I%2-1)),[J,G,U]=I<1?[E,D,0]:I<2?[D,E,0]:I<3?[0,E,D]:I<4?[0,D,E]:I<5?[D,0,E]:[E,0,D],Y=B-E/2;return hH([(J+Y)*255,(G+Y)*255,(U+Y)*255])}function SU(A,Q=1){return A.endsWith("%")?parseFloat(A)/100*Q:parseFloat(A)}function Zh(A,Q="#ffffff"){let B=A.trim().toLowerCase();if(/^#[0-9a-f]{3}$/.test(B))return`#${[...B.slice(1)].map((H)=>H+H).join("")}`;if(GAQ(B))return B;let E=/^(oklch|rgba?|hsla?)?\(?\s*([^)]*?)\s*\)?$/.exec(B);if(!E)throw Error(`Unsupported color "${A}"`);let[I,D]=E[2].split("/").map((H)=>H.trim()),J=I.split(/[\s,]+/).filter(Boolean);if(J.length!==3)throw Error(`Unsupported color "${A}"`);let G=E[1]??"hsl",U=G==="oklch"?CAQ(SU(J[0]),SU(J[1],0.4),parseFloat(J[2])):G.startsWith("rgb")?hH(J.map((H)=>SU(H,255))):$AQ(parseFloat(J[0]),SU(J[1]),SU(J[2])),Y=D===void 0?1:SU(D);return Y>=1?U:XQ(Q,U,Y)}var m2A;var HM=W(()=>{m2A=/^#([0-9a-f]{6})$/i});function bU(A,Q){return Q.find((B)=>rE(B,A)>=4.5)??c2A(A,Q)}function xU(A){let Q=A.scheme==="dark",B=Q?i2A:d2A,{background:E,foreground:I,primary:D}=A,J=A.card??(Q?XQ(E,I,0.04):XQ(E,"#ffffff",0.75)),G=A.muted??XQ(E,I,Q?0.05:0.035),U=A.secondary??XQ(E,I,Q?0.09:0.06),Y=A.accent??XQ(E,I,Q?0.11:0.075),H=[E,J,G],X=(w)=>wU(w,H,I),N=A.primaryForeground??bU(D,[E,I,...vU]),z=A.highlight??(Q?XQ(E,D,0.3):XQ(D,"#ffffff",0.7)),F=X(A.ring??D),V=A.sidebar??(Q?XQ(E,"#000000",0.3):XQ(E,I,0.03)),O=A.sidebarAccent??XQ(V,I,Q?0.1:0.07),j=bU(O,[I,E,...vU]),b=Object.fromEntries(UAQ.map((w)=>[w,A.tokens?.[w]??X(A[w]??B[w])])),x=Object.fromEntries(YAQ.map((w)=>[w,X(B[w])])),v={background:E,foreground:I,card:J,primary:D,"primary-foreground":N,"primary-ink":X(A.primaryInk??D),secondary:U,"secondary-foreground":bU(U,[I,E,...vU]),muted:G,"muted-foreground":W8(A.mutedForeground??XQ(I,E,0.42),[...H,Y],4.5,I),accent:Y,"accent-foreground":bU(Y,[I,E,...vU]),...b,"destructive-foreground":bU(b.destructive,[E,I,...vU]),border:A.border??XQ(E,I,Q?0.14:0.11),input:A.input??XQ(E,I,Q?0.28:0.3),ring:F,highlight:z,"highlight-foreground":bU(z,[I,E,...vU]),overlay:Q?"rgb(0 0 0 / 60%)":l2A(XQ(I,"#000000",0.4),0.2),"chart-1":D,"chart-2":XQ(I,E,0.45),"chart-3":b.info,"chart-4":b.warning,"chart-5":b.success,sidebar:V,"sidebar-foreground":W8(XQ(I,V,0.15),[V],4.5,I),"sidebar-primary":D,"sidebar-primary-foreground":N,"sidebar-accent":O,"sidebar-accent-foreground":j,"sidebar-border":XQ(V,I,Q?0.1:0.09),"sidebar-ring":F,...x};return{id:A.id,name:A.name,description:A.description,scheme:A.scheme,special:!0,palette:A.palette,tokens:HAQ({...v,...A.tokens})}}function KAQ(A,Q){let B=(D)=>Q.every(([J,G])=>rE(D,J)>=G);if(B(A))return A;let E=Q.every(([D])=>rE("#000000",D)>=rE("#ffffff",D)),I=A;for(let D of E?["#000000"]:[Xh(A),"#ffffff"]){for(let J=1;J<=40;J+=1){let G=XQ(I,D,J/40);if(B(G))return G}I=D}return E?"#000000":"#ffffff"}function HAQ(A){let Q={...A};for(let B of[...new Set(p2A.map(([E])=>E))]){let E=p2A.filter(([I])=>I===B).map(([,I,D])=>[Q[I],D]);Q[B]=KAQ(Q[B],E)}return Q}function ZAQ(A){return Object.fromEntries([...A.matchAll(/--([a-z0-9-]+)\s*:\s*([^;]+);/gi)].map((Q)=>[Q[1].toLowerCase(),Q[2].trim()]))}function kU(A){let Q=ZAQ(A.css);for(let X of["background","foreground","primary"])if(!Q[X])throw Error(`The ${A.name} export has no --${X}`);let B=Zh(Q.background),E=Object.fromEntries(XAQ.filter((X)=>Q[X]).map((X)=>[X,Zh(Q[X],B)])),{foreground:I,primary:D}=E,J=E.card??B,G=(X)=>X!==void 0&&rE(X,B)>=4.5&&rE(X,J)>=4.5,U=E["primary-foreground"],Y=G(D)?D:G(U)?U:void 0,H=E.input&&rE(E.input,B)<1.8?W8(E.input,[B],1.8,I):E.input;return xU({id:A.id,name:A.name,description:A.description,scheme:A.scheme,palette:A.palette??[B,D,E["sidebar-primary"]??D,E["chart-2"]??D,I].filter((X,N,z)=>z.indexOf(X)===N),background:B,foreground:I,primary:D,primaryForeground:U,primaryInk:Y,card:E.card,secondary:E.secondary,accent:E.accent,muted:E.muted,mutedForeground:E["muted-foreground"],border:E.border,input:H,ring:E.ring,sidebar:E.sidebar,sidebarAccent:E["sidebar-accent"],destructive:E.destructive,tokens:H?{...E,input:H}:E})}function X$(A){return Nh.find((Q)=>Q.id===A)}var d2A,i2A,vU,UAQ,YAQ,p2A,XAQ,XM,uH,NAQ,Nh;var zh=W(()=>{HM();d2A={background:"#ffffff",foreground:"#222321",card:"#ffffff",primary:"#262923","primary-foreground":"#ffffff","primary-ink":"#262923",secondary:"#f1f1ee","secondary-foreground":"#222321",muted:"#f6f6f3","muted-foreground":"#656660",accent:"#eeeee9","accent-foreground":"#222321",destructive:"#a52d2d","destructive-foreground":"#ffffff",border:"#e3e3df",input:"#b9bbb3",ring:"#3457a5",success:"#296844",warning:"#805400",info:"#315f9a",highlight:"#edf26a","highlight-foreground":"#222321",overlay:"rgb(20 22 20 / 18%)","chart-1":"#262923","chart-2":"#6b6c66","chart-3":"#315f9a","chart-4":"#805400","chart-5":"#296844",sidebar:"#f4f3f1","sidebar-foreground":"#44453f","sidebar-primary":"#222321","sidebar-primary-foreground":"#ffffff","sidebar-accent":"#e9e8e4","sidebar-accent-foreground":"#222321","sidebar-border":"#e3e3df","sidebar-ring":"#3457a5","tag-gray":"#6b6c66","tag-red":"#c03a2b","tag-orange":"#b35309","tag-amber":"#8f6200","tag-green":"#2e7d4f","tag-teal":"#0f7470","tag-blue":"#2f62b8","tag-purple":"#7a4cc0","tag-pink":"#b23a7a"},i2A={background:"#141513",foreground:"#ecece7",card:"#1b1c1a",primary:"#ecece7","primary-foreground":"#1b1c1a","primary-ink":"#ecece7",secondary:"#262724","secondary-foreground":"#ecece7",muted:"#1e1f1d","muted-foreground":"#a3a49c",accent:"#2a2b28","accent-foreground":"#ecece7",destructive:"#ec6a5e","destructive-foreground":"#141513",border:"#2d2e2b",input:"#4b4c47",ring:"#7d9ce6",success:"#5dbe80",warning:"#e2a83c",info:"#7ca5e8",highlight:"#4a4c1e","highlight-foreground":"#ecece7",overlay:"rgb(0 0 0 / 55%)","chart-1":"#ecece7","chart-2":"#8b8c85","chart-3":"#7ca5e8","chart-4":"#e2a83c","chart-5":"#5dbe80",sidebar:"#10110f","sidebar-foreground":"#c4c5bd","sidebar-primary":"#ecece7","sidebar-primary-foreground":"#141513","sidebar-accent":"#242522","sidebar-accent-foreground":"#ecece7","sidebar-border":"#262724","sidebar-ring":"#7d9ce6","tag-gray":"#9c9d95","tag-red":"#f2766b","tag-orange":"#f0954f","tag-amber":"#e3b341","tag-green":"#5dbe80","tag-teal":"#3fc1b4","tag-blue":"#79a3ee","tag-purple":"#b48ff0","tag-pink":"#ee82b8"},vU=["#000000","#ffffff"],UAQ=["destructive","success","warning","info"],YAQ=["tag-gray","tag-red","tag-orange","tag-amber","tag-green","tag-teal","tag-blue","tag-purple","tag-pink"];p2A=[["foreground","background",7],["foreground","card",7],["foreground","muted",7],["muted-foreground","background",4.5],["muted-foreground","card",4.5],["muted-foreground","muted",4.5],["muted-foreground","accent",4.5],["primary-ink","background",4.5],["primary-ink","card",4.5],["primary-foreground","primary",4.5],["secondary-foreground","secondary",4.5],["accent-foreground","accent",4.5],["destructive","background",4.5],["destructive","card",4.5],["destructive-foreground","destructive",4.5],["success","background",4.5],["success","card",4.5],["warning","background",4.5],["warning","card",4.5],["info","background",4.5],["info","card",4.5],["highlight-foreground","highlight",4.5],["sidebar-foreground","sidebar",4.5],["sidebar-foreground","sidebar-accent",4.5],["sidebar-accent-foreground","sidebar-accent",4.5],["sidebar-primary-foreground","sidebar-primary",4.5],["ring","background",4.5],["ring","card",4.5],["sidebar-ring","sidebar",3],["chart-1","background",3],["chart-1","card",3],...["gray","red","orange","amber","green","teal","blue","purple","pink"].flatMap((A)=>[[`tag-${A}`,"background",4.5],[`tag-${A}`,"muted",4.5]])];XAQ=["background","foreground","card","primary","primary-foreground","secondary","secondary-foreground","muted","muted-foreground","accent","accent-foreground","destructive","border","input","ring","chart-1","chart-2","chart-3","chart-4","chart-5","sidebar","sidebar-foreground","sidebar-primary","sidebar-primary-foreground","sidebar-accent","sidebar-accent-foreground","sidebar-border","sidebar-ring"];XM={id:"light",name:"Light",description:"Oatmilk's bright, quiet default.",scheme:"light",special:!1,palette:["#ffffff","#f4f3f1","#262923","#edf26a"],tokens:d2A},uH={id:"dark",name:"Dark",description:"Easy on the eyes after hours.",scheme:"dark",special:!1,palette:["#141513","#1b1c1a","#ecece7","#7d9ce6"],tokens:i2A},NAQ=[xU({id:"marathon",name:"Marathon",description:"Acid volt on black, with signal red and arc blue.",scheme:"dark",palette:["#c0fc04","#000000","#b10702","#0a65fe","#819074"],background:"#000000",foreground:"#fefef7",primary:"#c0fc04",primaryForeground:"#000000",card:XQ("#000000","#819074",0.08),muted:XQ("#000000","#819074",0.1),secondary:XQ("#000000","#819074",0.16),accent:XQ("#000000","#819074",0.2),mutedForeground:"#819074",border:XQ("#000000","#819074",0.24),input:XQ("#000000","#819074",0.5),sidebar:"#000000",sidebarAccent:XQ("#000000","#c0fc04",0.16),destructive:"#b10702",info:"#0a65fe",tokens:{"chart-2":"#819074","tag-red":wU("#b10702",["#000000","#0d0e0c"],"#fefef7"),"tag-blue":wU("#0a65fe",["#000000","#0d0e0c"],"#fefef7")}}),xU({id:"limelight",name:"Limelight",description:"Warm paper and charcoal, lit with electric lime.",scheme:"light",palette:["#9c9b9a","#f6f5f2","#353535","#e4f222"],background:"#f6f5f2",foreground:"#353535",primary:"#353535",primaryForeground:"#f6f5f2",card:"#ffffff",mutedForeground:"#9c9b9a",border:XQ("#f6f5f2","#9c9b9a",0.3),input:"#9c9b9a",ring:"#e4f222",highlight:"#e4f222",sidebarAccent:"#e4f222",tokens:{"chart-2":"#9c9b9a"}}),xU({id:"meadow",name:"Meadow",description:"Sunlit yellow and soft sage on cream.",scheme:"light",palette:["#e9dd4e","#dbdd59","#a5bb88","#9ab991"],background:XQ("#e9dd4e","#ffffff",0.9),foreground:XQ("#9ab991","#000000",0.8),primary:XQ("#a5bb88","#000000",0.6),secondary:XQ("#dbdd59","#ffffff",0.7),accent:XQ("#a5bb88","#ffffff",0.7),border:XQ("#a5bb88","#ffffff",0.65),input:"#9ab991",ring:"#9ab991",highlight:"#e9dd4e",sidebar:XQ("#dbdd59","#ffffff",0.82),sidebarAccent:"#a5bb88",tokens:{"chart-2":"#9ab991"}}),xU({id:"dusk",name:"Dusk",description:"Desert browns and lamp-lit taupe after sundown.",scheme:"dark",palette:["#786453","#7e674f","#181415","#575755"],background:"#181415",foreground:XQ("#786453","#ffffff",0.88),primary:XQ("#7e674f","#ffffff",0.4),primaryForeground:"#181415",card:XQ("#181415","#786453",0.08),muted:XQ("#181415","#786453",0.1),secondary:"#575755",accent:XQ("#181415","#786453",0.25),border:XQ("#181415","#786453",0.3),input:"#575755",highlight:"#786453",sidebar:XQ("#181415","#000000",0.3),sidebarAccent:XQ("#181415","#7e674f",0.3),tokens:{"chart-2":"#7e674f"}}),xU({id:"nocturne",name:"Nocturne",description:"Midnight glass and deep teal, like a city at 3 a.m.",scheme:"dark",palette:["#020a10","#050a0c","#010204","#192423"],background:"#050a0c",foreground:XQ("#192423","#ffffff",0.88),primary:XQ("#192423","#ffffff",0.62),primaryForeground:"#010204",card:XQ("#050a0c","#192423",0.45),muted:XQ("#050a0c","#192423",0.5),secondary:"#192423",accent:"#192423",border:"#192423",input:XQ("#192423","#ffffff",0.2),sidebar:"#020a10",sidebarAccent:"#192423",tokens:{"chart-2":XQ("#192423","#ffffff",0.3)}}),kU({id:"matcha",name:"Matcha",description:"Bright lime on clean white, with soft olive grays.",scheme:"light",css:`
305
+ `))return E;E=A.indexOf(Q,E+1)}return-1}function O2A(A){return A instanceof AE&&A.status>=400&&A.status<500&&A.status!==408&&A.status!==425}function L2A(A,Q=[],B={}){let E=A.stream.bind(A),I=A.snapshot.bind(A),D=A.send.bind(A),J=A.respond.bind(A),G=new Map,U=new Set,Y=new Set,H=!1,X=!1,N=!1,z=Promise.resolve(),F=async(v,w)=>{let k=new AbortController,h=w?AbortSignal.any([w,k.signal]):k.signal,t=setTimeout(()=>k.abort(new DOMException("Loading the chat before sending timed out.","TimeoutError")),5000),i,UA=new Promise((CA,GA)=>{if(i=()=>GA(h.reason),h.addEventListener("abort",i,{once:!0}),h.aborted)i()});try{let CA=await Promise.race([I({signal:h}),UA]);v.priorReceipts=new Set(CA.events.flatMap((GA)=>(GA.type==="message.received"||GA.type==="input.resolved")&&GA.meta?.id!==void 0?[GA.meta.id]:[]))}catch(CA){if(h.throwIfAborted(),CA instanceof Error&&(CA.name==="AbortError"||CA.name==="TimeoutError"))throw CA}finally{clearTimeout(t),h.removeEventListener("abort",i)}},V=(v,w)=>{w?.throwIfAborted();let k=z.then(v);if(z=k.then(()=>{return},()=>{return}),!w)return k;return new Promise((h,t)=>{let i=()=>t(w.reason);w.addEventListener("abort",i,{once:!0}),k.then((UA)=>{w.removeEventListener("abort",i),h(UA)},(UA)=>{w.removeEventListener("abort",i),t(UA)})})},O=(v)=>{if(v.type==="turn.started")H=!1,N=!1;else if(v.type==="message.received"&&(v.meta?.id===void 0||!U.has(v.meta.id))){if(v.meta?.id!==void 0)U.add(v.meta.id);H=!1,N=!1;let w=0,k=0,h=0,t=v.data.parts?.map((i)=>i.type==="text"?i.text:null);for(let[i,UA]of G){if(!("message"in UA))continue;if(!UA.dispatched)break;if(v.meta?.id!==void 0&&UA.priorReceipts?.has(v.meta.id))continue;if(t&&UA.parts){let GA=k;if(UA.structured){if(h)GA+=1;let iA;for(;GA<t.length;GA+=1)if(iA=[UA.parts,UA.foldedParts??UA.parts].find((jA)=>jA.length>0&&jA.every((IQ,_A)=>t[GA+_A]===IQ)),iA!==void 0)break;if(iA===void 0)break;k=GA+iA.length,h=0}else{let iA=-1;for(;GA<t.length;GA+=1){let jA=t[GA];if(jA!==null)iA=_2A(jA,UA.message,GA===k?h:0);if(iA!==-1)break}if(iA===-1)break;if(k=GA,h=iA+UA.message.length+2,h>t[GA].length)k+=1,h=0}G.delete(i);continue}let CA=_2A(v.data.message,UA.message,w);if(CA===-1)break;G.delete(i),w=CA+UA.message.length+2}}else if(v.type==="input.resolved"&&(v.meta?.id===void 0||!U.has(v.meta.id))){if(v.meta?.id!==void 0)U.add(v.meta.id);H=!1,N=!1;for(let[w,k]of G){if(!("responses"in k))continue;if(!k.dispatched)continue;if(v.meta?.id!==void 0&&k.priorReceipts?.has(v.meta.id))continue;for(let h of v.data.resolutions)k.responses.delete(h.requestId);if(!k.responses.size)G.delete(w)}}else if(v.type==="authorization.required"&&v.data.webhookUrl!==void 0)Y.add(v.data.name);else if(v.type==="authorization.completed")Y.delete(v.data.name),H=!1;else if(v.type==="session.waiting")H=!0;else if(v.type==="session.completed"||v.type==="session.failed")H=!0,X=!0},j=()=>X||H&&!N&&G.size===0&&Y.size===0;for(let v of Q)O(v);N=B.pendingTurn??!1;let b=async function*(v,w=!1){for await(let k of v)if(O(k),yield k,w&&j()&&(k.type==="session.waiting"||k.type==="session.completed"||k.type==="session.failed"))return},x=(v)=>{let w=v[Symbol.asyncIterator].bind(v);return v[Symbol.asyncIterator]=()=>{let k=w();return b({[Symbol.asyncIterator]:()=>k})},v};return A.send=async(v,w)=>{let k={},h={...aeA(v),dispatched:!1};G.set(k,h);try{return x(await V(async()=>{w?.signal?.throwIfAborted(),await F(h,w?.signal);try{return await D(v,{...w,headers:V2A(h,w?.headers,w?.signal)})}catch(t){if(O2A(t))G.delete(k);throw t}},w?.signal))}catch(t){if(!h.dispatched)G.delete(k);throw t}},A.respond=async(v,w)=>{let k={},h={responses:new Set(v.map((t)=>t.requestId)),dispatched:!1};G.set(k,h);try{return x(await V(async()=>{w?.signal?.throwIfAborted(),await F(h,w?.signal);try{return await J(v,{...w,headers:V2A(h,w?.headers,w?.signal)})}catch(t){if(O2A(t))G.delete(k);throw t}},w?.signal))}catch(t){if(!h.dispatched)G.delete(k);throw t}},A.stream=(v={})=>{let w=v.streamReconnectPolicy!==void 0&&"reconnect"in v.streamReconnectPolicy&&v.streamReconnectPolicy.reconnect===!1;if(v.follow===!1||v.streamReconnectPolicy!==void 0&&!(N&&w))return b(E(v));return b(E({...v,streamReconnectPolicy:j()?{reconnect:!1}:{streamIdleReconnectPolicy:{maxAttempts:Number.POSITIVE_INFINITY}}}),!0)},A}var W2A=W(()=>{wH()});function $M(A){return`${A.host}/api/accounting/agent`}function Gh(A){return{bearer:()=>A.token()}}function Ch(A,Q){return{...p8(),...A.organizationId?{"x-accounting-organization":A.organizationId}:{},...Dh(Q)}}function bH(A,Q){return new TH({host:$M(A),auth:Gh(A),headers:()=>Ch(A,Q()),redirect:"error"})}function kH(A,Q,B,E=0){return L2A(bH(A,Q).sessions.attach(B,{streamIndex:E}))}async function UG(A,Q=fetch){let B=await Q(`${$M(A)}/sessions`,{headers:{...await A.headers(),accept:"application/json"},redirect:"error"}),E=await B.json().catch(()=>null);if(!B.ok)throw new mQ(E?.error?.code??`HTTP_${B.status}`,E?.error?.message??"Couldn't load your recent chats.",B.status);return Array.isArray(E?.data?.chats)?E.data.chats:[]}function Y$(A){if(!(A instanceof AE))return A;let Q;try{Q=JSON.parse(A.body)}catch{Q=null}let B=typeof Q?.code==="string"?Q.code:A.code??`HTTP_${A.status}`,E=typeof Q?.error==="string"?Q.error:typeof Q?.message==="string"?Q.message:`Ask AI answered ${A.status}.`;return new mQ(B,E,A.status)}var j2A=1800000;var PU=W(()=>{wH();l1();W2A();D6();wQ()});var xH;var $h=W(()=>{xH={accounting_accountant_access_get:["accountant.access.get","read"],accounting_accountant_changes_list:["accountant.changes.list","read"],accounting_accountant_changes_request:["accountant.changes.request","write"],accounting_accountant_comments_create:["accountant.comments.create","write"],accounting_accountant_comments_list:["accountant.comments.list","read"],accounting_accountant_requests_create:["accountant.requests.create","write"],accounting_accountant_slips_readiness:["accountant.slips.readiness","read"],accounting_accountant_tax_request:["accountant.tax.request","write"],accounting_accountant_welcome_update:["accountant.welcome.update","write"],accounting_accountants_access_update:["accountants.access.update","access"],accounting_accountants_activity:["accountants.activity","read"],accounting_accountants_comments_list:["accountants.comments.list","read"],accounting_accountants_comments_reply:["accountants.comments.reply","write"],accounting_accountants_comments_resolve:["accountants.comments.resolve","write"],accounting_accountants_grants_revoke:["accountants.grants.revoke","destructive"],accounting_accountants_invitations_link:["accountants.invitations.link","access"],accounting_accountants_invitations_preview:["accountants.invitations.preview","read"],accounting_accountants_invitations_resend:["accountants.invitations.resend","external"],accounting_accountants_invitations_revoke:["accountants.invitations.revoke","destructive"],accounting_accountants_invitations_update:["accountants.invitations.update","access"],accounting_accountants_invite:["accountants.invite","external"],accounting_accountants_invite_many:["accountants.inviteMany","external"],accounting_accountants_list:["accountants.list","read"],accounting_accountants_remove:["accountants.remove","destructive"],accounting_accountants_requests_decide:["accountants.requests.decide","access"],accounting_accounts_create:["accounts.create","write"],accounting_accounts_lifecycle:["accounts.lifecycle","write"],accounting_accounts_lifecycle_preview:["accounts.lifecycle.preview","read"],accounting_accounts_update:["accounts.update","write"],accounting_agents_overview:["agents.overview","read"],accounting_agents_playground_match:["agents.playground.match","read"],accounting_agents_playground_receipt:["agents.playground.receipt","read"],accounting_ai_keys_get:["ai.keys.get","read"],accounting_ai_keys_remove:["ai.keys.remove","write"],accounting_ai_keys_save:["ai.keys.save","write"],accounting_ai_models_list:["ai.models.list","read"],accounting_ai_sandbox_evaluate:["ai.sandbox.evaluate","read"],accounting_ai_settings_get:["ai.settings.get","read"],accounting_ai_settings_update:["ai.settings.update","write"],accounting_api_keys_create:["api_keys.create","access"],accounting_api_keys_list:["api_keys.list","read"],accounting_api_keys_revoke:["api_keys.revoke","destructive"],accounting_api_keys_rotate:["api_keys.rotate","destructive"],accounting_attach_receipt:["entries.attachReceipt","write"],accounting_attention_list:["attention.list","read"],accounting_attention_mine:["attention.mine","read"],accounting_autopilot_classify:["autopilot.classify","write"],accounting_autopilot_explain:["autopilot.explain","read"],accounting_autopilot_jobs_cancel:["autopilot.jobs.cancel","write"],accounting_autopilot_jobs_get:["autopilot.jobs.get","read"],accounting_autopilot_jobs_list:["autopilot.jobs.list","read"],accounting_autopilot_jobs_start:["autopilot.jobs.start","write"],accounting_autopilot_rules_list:["autopilot.rules.list","read"],accounting_autopilot_rules_update:["autopilot.rules.update","write"],accounting_autopilot_settings_get:["autopilot.settings.get","read"],accounting_autopilot_settings_update:["autopilot.settings.update","write"],accounting_autopilot_status:["autopilot.status","read"],accounting_autopilot_summary:["autopilot.summary","read"],accounting_budgets_accounts_designate:["budgets.accounts.designate","write"],accounting_budgets_accounts_get:["budgets.accounts.get","read"],accounting_budgets_evaluate:["budgets.evaluate","write"],accounting_budgets_get:["budgets.get","read"],accounting_budgets_obligations_get:["budgets.obligations.get","read"],accounting_budgets_obligations_save:["budgets.obligations.save","write"],accounting_budgets_overview:["budgets.overview","read"],accounting_budgets_save:["budgets.save","write"],accounting_bulk_categorize:["entries.bulkCategorize","write"],accounting_calendar_events:["calendar.events","read"],accounting_cards_claim:["cards.claim","write"],accounting_cards_claimable:["cards.claimable","read"],accounting_cards_list:["cards.list","read"],accounting_cards_prompt_dismiss:["cards.prompt.dismiss","write"],accounting_cards_save:["cards.save","write"],accounting_cards_set_account_type:["cards.setAccountType","write"],accounting_categories_add_recommended:["categories.addRecommended","write"],accounting_chase_preferences_get:["chase.preferences.get","read"],accounting_chase_preferences_update:["chase.preferences.update","write"],accounting_chase_preview:["chase.preview","read"],accounting_chase_run:["chase.run","external"],accounting_chief_of_staff_channels_update:["chiefOfStaff.channels.update","access"],accounting_chief_of_staff_general_update:["chiefOfStaff.general.update","access"],accounting_chief_of_staff_people_find:["chiefOfStaff.people.find","read"],accounting_chief_of_staff_rules_delete:["chiefOfStaff.rules.delete","access"],accounting_chief_of_staff_rules_save:["chiefOfStaff.rules.save","access"],accounting_chief_of_staff_schedules_update:["chiefOfStaff.schedules.update","access"],accounting_chief_of_staff_servers_list:["chiefOfStaff.servers.list","read"],accounting_chief_of_staff_servers_update:["chiefOfStaff.servers.update","access"],accounting_chief_of_staff_settings_get:["chiefOfStaff.settings.get","read"],accounting_chief_of_staff_status:["chiefOfStaff.status","read"],accounting_classifier_mailboxes_list:["classifier.mailboxes.list","read"],accounting_classifier_mailboxes_save:["classifier.mailboxes.save","write"],accounting_close_period:["reconciliation.close","write"],accounting_commit_bank_import:["imports.commit","write"],accounting_company_apply_record:["company.applyRecord","write"],accounting_company_close:["company.close","destructive"],accounting_company_export:["company.export","write"],accounting_company_export_files:["company.export.files","read"],accounting_company_facts_apply:["company.facts.apply","write"],accounting_company_facts_review:["company.facts.review","read"],accounting_company_get:["company.get","read"],accounting_company_record_changes:["company.recordChanges","read"],accounting_company_shareholders_export:["company.shareholders.export","write"],accounting_company_shareholders_get:["company.shareholders.get","read"],accounting_company_shareholders_tax_number:["company.shareholders.taxNumber","write"],accounting_company_shareholders_update:["company.shareholders.update","write"],accounting_company_update:["company.update","write"],accounting_compliance_checklist:["compliance.checklist","read"],accounting_compliance_items_create:["compliance.items.create","write"],accounting_compliance_items_get:["compliance.items.get","read"],accounting_compliance_items_list:["compliance.items.list","read"],accounting_compliance_items_update:["compliance.items.update","write"],accounting_compliance_kickoff_run:["compliance.kickoff.run","write"],accounting_compliance_library_entries_create:["complianceLibrary.entries.create","write"],accounting_compliance_library_entries_update:["complianceLibrary.entries.update","write"],accounting_compliance_library_files_confirm:["complianceLibrary.files.confirm","write"],accounting_compliance_library_files_prepare:["complianceLibrary.files.prepare","write"],accounting_compliance_library_get:["complianceLibrary.get","read"],accounting_compliance_library_inputs_add_url:["complianceLibrary.inputs.addUrl","write"],accounting_compliance_library_inputs_retry:["complianceLibrary.inputs.retry","write"],accounting_compliance_library_list:["complianceLibrary.list","read"],accounting_compliance_library_proposals_decide:["complianceLibrary.proposals.decide","write"],accounting_compliance_portal_overview:["compliancePortal.overview","read"],accounting_compliance_portal_search:["compliancePortal.search","read"],accounting_compliance_refresh:["compliance.refresh","write"],accounting_compliance_reminders_preview:["compliance.reminders.preview","read"],accounting_compliance_reminders_send_now:["compliance.reminders.sendNow","external"],accounting_compliance_research_chat_ask:["complianceResearch.chat.ask","external"],accounting_compliance_research_chat_history:["complianceResearch.chat.history","read"],accounting_compliance_research_findings_update:["complianceResearch.findings.update","write"],accounting_compliance_research_overview:["complianceResearch.overview","read"],accounting_compliance_research_run:["complianceResearch.run","external"],accounting_compliance_research_settings_update:["complianceResearch.settings.update","write"],accounting_compliance_research_sources_add:["complianceResearch.sources.add","write"],accounting_compliance_research_sources_remove:["complianceResearch.sources.remove","destructive"],accounting_compliance_research_suggestions_decide:["complianceResearch.suggestions.decide","write"],accounting_compliance_research_suggestions_list:["complianceResearch.suggestions.list","read"],accounting_confirm_matching:["matching.confirm","write"],accounting_confirm_upload:["uploads.confirm","write"],accounting_connectors_credentials_remove:["connectors.credentials.remove","destructive"],accounting_connectors_credentials_save:["connectors.credentials.save","write"],accounting_connectors_get:["connectors.get","read"],accounting_connectors_google_drive_connect:["connectors.googleDrive.connect","write"],accounting_connectors_google_drive_status:["connectors.googleDrive.status","read"],accounting_connectors_list:["connectors.list","read"],accounting_connectors_test:["connectors.test","external"],accounting_connectors_update:["connectors.update","write"],accounting_connectors_wise_signing_key_create:["connectors.wise.signingKey.create","write"],accounting_connectors_wise_statement_access:["connectors.wise.statementAccess","read"],accounting_connectors_wise_statements_check:["connectors.wise.statements.check","write"],accounting_contractor_ops_activity_list:["contractorOps.activity.list","read"],accounting_contractor_ops_agreements_add_contractor:["contractorOps.agreements.addContractor","write"],accounting_contractor_ops_agreements_contractor_draft:["contractorOps.agreements.contractorDraft","read"],accounting_contractor_ops_agreements_ended:["contractorOps.agreements.ended","read"],accounting_contractor_ops_agreements_import_executed:["contractorOps.agreements.importExecuted","write"],accounting_contractor_ops_agreements_keep_as_history:["contractorOps.agreements.keepAsHistory","write"],accounting_contractor_ops_agreements_link_contractor:["contractorOps.agreements.linkContractor","write"],accounting_contractor_ops_agreements_list:["contractorOps.agreements.list","read"],accounting_contractor_ops_agreements_send_template:["contractorOps.agreements.sendTemplate","external"],accounting_contractor_ops_agreements_unlinked:["contractorOps.agreements.unlinked","read"],accounting_contractor_ops_directory_list:["contractorOps.directory.list","read"],accounting_contractor_ops_encryption_reset_fingerprint_key:["contractorOps.encryption.resetFingerprintKey","destructive"],accounting_contractor_ops_encryption_status:["contractorOps.encryption.status","read"],accounting_contractor_ops_forms_list:["contractorOps.forms.list","read"],accounting_contractor_ops_forms_save:["contractorOps.forms.save","write"],accounting_contractor_ops_history_allocations_get:["contractorOps.history.allocations.get","read"],accounting_contractor_ops_history_allocations_save:["contractorOps.history.allocations.save","write"],accounting_contractor_ops_history_list:["contractorOps.history.list","read"],accounting_contractor_ops_history_mark_paid:["contractorOps.history.markPaid","access"],accounting_contractor_ops_history_payment_asks_answer:["contractorOps.history.paymentAsks.answer","write"],accounting_contractor_ops_history_payment_asks_list:["contractorOps.history.paymentAsks.list","read"],accounting_contractor_ops_history_rate_backfill_apply:["contractorOps.history.rateBackfill.apply","write"],accounting_contractor_ops_history_rate_backfill_preview:["contractorOps.history.rateBackfill.preview","read"],accounting_contractor_ops_hours_history:["contractorOps.hours.history","read"],accounting_contractor_ops_import_agreements:["contractorOps.import.agreements","write"],accounting_contractor_ops_import_contractors:["contractorOps.import.contractors","write"],accounting_contractor_ops_import_hours:["contractorOps.import.hours","write"],accounting_contractor_ops_import_hours_sync:["contractorOps.import.hoursSync","external"],accounting_contractor_ops_import_hours_sync_status:["contractorOps.import.hoursSyncStatus","read"],accounting_contractor_ops_insights_get:["contractorOps.insights.get","read"],accounting_contractor_ops_payments_reveal:["contractorOps.payments.reveal","write"],accounting_contractor_ops_payments_update:["contractorOps.payments.update","access"],accounting_contractor_ops_payments_verify:["contractorOps.payments.verify","access"],accounting_contractor_ops_payouts_approve:["contractorOps.payouts.approve","access"],accounting_contractor_ops_payouts_cancel:["contractorOps.payouts.cancel","destructive"],accounting_contractor_ops_payouts_get:["contractorOps.payouts.get","read"],accounting_contractor_ops_payouts_list:["contractorOps.payouts.list","read"],accounting_contractor_ops_payouts_mark_paid:["contractorOps.payouts.markPaid","access"],accounting_contractor_ops_payouts_prepare:["contractorOps.payouts.prepare","write"],accounting_contractor_ops_payouts_send:["contractorOps.payouts.send","external"],accounting_contractor_ops_periods_list:["contractorOps.periods.list","read"],accounting_contractor_ops_periods_update:["contractorOps.periods.update","write"],accounting_contractor_ops_profiles_get:["contractorOps.profiles.get","read"],accounting_contractor_ops_profiles_update:["contractorOps.profiles.update","write"],accounting_contractor_ops_reminders_run:["contractorOps.reminders.run","external"],accounting_contractor_ops_roles_archive:["contractorOps.roles.archive","destructive"],accounting_contractor_ops_roles_archive_job:["contractorOps.roles.archiveJob","destructive"],accounting_contractor_ops_roles_assign:["contractorOps.roles.assign","write"],accounting_contractor_ops_roles_duplicate_job:["contractorOps.roles.duplicateJob","write"],accounting_contractor_ops_roles_get:["contractorOps.roles.get","read"],accounting_contractor_ops_roles_import:["contractorOps.roles.import","write"],accounting_contractor_ops_roles_list:["contractorOps.roles.list","read"],accounting_contractor_ops_roles_reorder:["contractorOps.roles.reorder","write"],accounting_contractor_ops_roles_save:["contractorOps.roles.save","write"],accounting_contractor_ops_roles_update_job:["contractorOps.roles.updateJob","write"],accounting_contractor_ops_roles_versions:["contractorOps.roles.versions","read"],accounting_contractor_ops_sales_tax_confirm:["contractorOps.salesTax.confirm","write"],accounting_contractor_ops_settings_get:["contractorOps.settings.get","read"],accounting_contractor_ops_settings_update:["contractorOps.settings.update","write"],accounting_contractor_ops_tax_forms_export:["contractorOps.taxForms.export","write"],accounting_contractor_ops_tax_forms_get:["contractorOps.taxForms.get","read"],accounting_contractor_ops_tax_info_get:["contractorOps.taxInfo.get","read"],accounting_contractor_ops_tax_info_list:["contractorOps.taxInfo.list","read"],accounting_contractor_ops_tax_info_request:["contractorOps.taxInfo.request","write"],accounting_contractor_ops_tax_info_update:["contractorOps.taxInfo.update","write"],accounting_contractor_ops_terms_cancel:["contractorOps.terms.cancel","destructive"],accounting_contractor_ops_terms_confirm:["contractorOps.terms.confirm","write"],accounting_contractor_ops_terms_end_decision:["contractorOps.terms.endDecision","write"],accounting_contractor_ops_terms_get:["contractorOps.terms.get","read"],accounting_contractor_ops_terms_link_role:["contractorOps.terms.linkRole","write"],accounting_contractor_ops_terms_propose:["contractorOps.terms.propose","write"],accounting_contractor_ops_terms_read:["contractorOps.terms.read","write"],accounting_contractor_ops_terms_set:["contractorOps.terms.set","write"],accounting_contractor_ops_timesheets_list:["contractorOps.timesheets.list","read"],accounting_contractor_ops_timesheets_review:["contractorOps.timesheets.review","write"],accounting_contractor_ops_title_change_override:["contractorOps.titleChange.override","write"],accounting_contractor_ops_title_change_plan:["contractorOps.titleChange.plan","read"],accounting_contractor_ops_title_change_propose:["contractorOps.titleChange.propose","write"],accounting_contractor_ops_wise_status:["contractorOps.wise.status","read"],accounting_contractors_access_reset:["contractors.access.reset","destructive"],accounting_contractors_agreements_create:["contractors.agreements.create","write"],accounting_contractors_agreements_download:["contractors.agreements.download","read"],accounting_contractors_agreements_get:["contractors.agreements.get","read"],accounting_contractors_agreements_list:["contractors.agreements.list","read"],accounting_contractors_agreements_remind:["contractors.agreements.remind","external"],accounting_contractors_agreements_revise:["contractors.agreements.revise","write"],accounting_contractors_agreements_send:["contractors.agreements.send","external"],accounting_contractors_agreements_void:["contractors.agreements.void","destructive"],accounting_contractors_create:["contractors.create","write"],accounting_contractors_email_update:["contractors.email.update","write"],accounting_contractors_files_confirm:["contractors.files.confirm","write"],accounting_contractors_files_prepare:["contractors.files.prepare","write"],accounting_contractors_get:["contractors.get","read"],accounting_contractors_hours_list:["contractors.hours.list","read"],accounting_contractors_hours_review:["contractors.hours.review","write"],accounting_contractors_invitations_fix_email:["contractors.invitations.fixEmail","external"],accounting_contractors_invitations_link:["contractors.invitations.link","write"],accounting_contractors_invitations_list:["contractors.invitations.list","read"],accounting_contractors_invitations_revoke:["contractors.invitations.revoke","destructive"],accounting_contractors_invite:["contractors.invite","external"],accounting_contractors_list:["contractors.list","read"],accounting_contractors_notifications_list:["contractors.notifications.list","read"],accounting_contractors_past_payments_link:["contractors.pastPayments.link","write"],accounting_contractors_past_payments_suggest:["contractors.pastPayments.suggest","read"],accounting_contractors_payments_bind:["contractors.payments.bind","write"],accounting_contractors_payments_get:["contractors.payments.get","read"],accounting_contractors_payments_identify:["contractors.payments.identify","write"],accounting_contractors_payments_jobs:["contractors.payments.jobs","read"],accounting_contractors_payments_link:["contractors.payments.link","write"],accounting_contractors_payments_list:["contractors.payments.list","read"],accounting_contractors_payments_unbind:["contractors.payments.unbind","destructive"],accounting_contractors_payments_unlink:["contractors.payments.unlink","destructive"],accounting_contractors_recipients_bind:["contractors.recipients.bind","write"],accounting_contractors_recipients_list:["contractors.recipients.list","read"],accounting_contractors_tax_profile_update:["contractors.taxProfile.update","write"],accounting_contractors_tax_report:["contractors.taxReport","read"],accounting_contractors_templates_create:["contractors.templates.create","write"],accounting_contractors_templates_download:["contractors.templates.download","read"],accounting_contractors_templates_list:["contractors.templates.list","read"],accounting_contractors_templates_preview:["contractors.templates.preview","read"],accounting_contractors_templates_update:["contractors.templates.update","write"],accounting_contractors_update:["contractors.update","write"],accounting_correct_bank_import:["transactions.correct","write"],accounting_create_bank_record:["reconciliation.createEntry","write"],accounting_create_category:["categories.create","write"],accounting_create_record:["entries.create","write"],accounting_data_imports_commit:["dataImports.commit","write"],accounting_data_imports_definitions:["dataImports.definitions","read"],accounting_data_imports_files:["dataImports.files","read"],accounting_data_imports_get:["dataImports.get","read"],accounting_data_imports_history:["dataImports.history","read"],accounting_data_imports_preview:["dataImports.preview","read"],accounting_data_imports_resume:["dataImports.resume","write"],accounting_data_imports_suggest:["dataImports.suggest","read"],accounting_data_imports_undo:["dataImports.undo","destructive"],accounting_data_sources_files:["dataSources.files","read"],accounting_data_sources_import_files:["dataSources.importFiles","write"],accounting_data_sources_list:["dataSources.list","read"],accounting_data_sources_pin:["dataSources.pin","write"],accounting_data_sources_read_text:["dataSources.readText","read"],accounting_data_sources_resolve:["dataSources.resolve","read"],accounting_data_sources_rows:["dataSources.rows","read"],accounting_data_sources_schema:["dataSources.schema","read"],accounting_data_sources_search:["dataSources.search","read"],accounting_developers_requests_list:["developers.requests.list","read"],accounting_developers_usage:["developers.usage","read"],accounting_document_requests_list:["documentRequests.list","read"],accounting_document_requests_recipients:["documentRequests.recipients","read"],accounting_document_requests_revoke:["documentRequests.revoke","destructive"],accounting_document_requests_send:["documentRequests.send","external"],accounting_documents_assets_confirm:["documents.assets.confirm","write"],accounting_documents_assets_list:["documents.assets.list","read"],accounting_documents_assets_prepare:["documents.assets.prepare","write"],accounting_documents_assets_update:["documents.assets.update","write"],accounting_documents_comments_create:["documents.comments.create","write"],accounting_documents_comments_list:["documents.comments.list","read"],accounting_documents_comments_members:["documents.comments.members","read"],accounting_documents_comments_reply:["documents.comments.reply","write"],accounting_documents_comments_resolve:["documents.comments.resolve","write"],accounting_documents_content_edit:["documents.content.edit","write"],accounting_documents_content_get:["documents.content.get","read"],accounting_documents_download:["documents.download","read"],accounting_documents_extract:["documents.extract","write"],accounting_documents_get:["documents.get","read"],accounting_documents_history_get:["documents.history.get","read"],accounting_documents_history_list:["documents.history.list","read"],accounting_documents_history_restore:["documents.history.restore","write"],accounting_documents_list:["documents.list","read"],accounting_documents_records_get:["documents.records.get","read"],accounting_documents_records_search:["documents.records.search","read"],accounting_documents_snippets_create:["documents.snippets.create","write"],accounting_documents_snippets_list:["documents.snippets.list","read"],accounting_documents_snippets_update:["documents.snippets.update","write"],accounting_documents_suggestions_create:["documents.suggestions.create","write"],accounting_documents_suggestions_decide:["documents.suggestions.decide","write"],accounting_documents_suggestions_list:["documents.suggestions.list","read"],accounting_documents_update:["documents.update","write"],accounting_edit_record:["entries.update","write"],accounting_email_domain_activate:["email.domain.activate","external"],accounting_email_domain_configure:["email.domain.configure","external"],accounting_email_domain_status:["email.domain.status","read"],accounting_email_domain_use_platform:["email.domain.usePlatform","write"],accounting_email_domain_verify:["email.domain.verify","external"],accounting_email_outbox_list:["email.outbox.list","read"],accounting_email_status:["email.status","read"],accounting_email_test:["email.test","external"],accounting_entries_context:["entries.context","read"],accounting_entries_delete:["entries.delete","destructive"],accounting_entries_delete_preview:["entries.delete.preview","read"],accounting_entries_deleted_list:["entries.deleted.list","read"],accounting_entries_evidence_confirm:["entries.evidence.confirm","write"],accounting_entries_evidence_prepare:["entries.evidence.prepare","write"],accounting_entries_hold_release_undo:["entries.hold.release.undo","write"],accounting_entries_hold_set:["entries.hold.set","write"],accounting_entries_place_set:["entries.place.set","write"],accounting_entries_restore:["entries.restore","write"],accounting_entries_retry_step:["entries.retryStep","write"],accounting_entries_tags_set:["entries.tags.set","write"],accounting_evidence_inbox_search_cancel:["evidence.inboxSearch.cancel","write"],accounting_evidence_inbox_search_get:["evidence.inboxSearch.get","read"],accounting_evidence_inbox_search_start:["evidence.inboxSearch.start","external"],accounting_exchange_rates_get:["exchangeRates.get","read"],accounting_experiments_get:["experiments.get","read"],accounting_experiments_update:["experiments.update","write"],accounting_export:["reports.export","write"],accounting_get_evidence:["evidence.download","read"],accounting_get_import_evidence:["imports.download","read"],accounting_get_record:["entries.get","read"],accounting_get_submission:["submissions.get","read"],accounting_handoff_export:["handoff.export","read"],accounting_handoff_get:["handoff.get","read"],accounting_handoff_update:["handoff.update","write"],accounting_history_facets:["history.facets","read"],accounting_history_get:["history.get","read"],accounting_history_list:["history.list","read"],accounting_history_rollback_apply:["history.rollback.apply","destructive"],accounting_history_rollback_apply_many:["history.rollback.applyMany","destructive"],accounting_history_rollback_preview:["history.rollback.preview","read"],accounting_history_rollback_preview_many:["history.rollback.previewMany","read"],accounting_identity_get:["identity.get","read"],accounting_imports_undo_apply:["imports.undo.apply","destructive"],accounting_imports_undo_history:["imports.undo.history","read"],accounting_imports_undo_preview:["imports.undo.preview","read"],accounting_imports_undo_restore:["imports.undo.restore","write"],accounting_inbox_address:["inbox.address","read"],accounting_insights_finance_get:["insights.finance.get","read"],accounting_insights_finance_trends:["insights.finance.trends","read"],accounting_insights_forecast_get:["insights.forecast.get","read"],accounting_insights_map_config_get:["insights.map.config.get","read"],accounting_insights_map_drilldown:["insights.map.drilldown","read"],accounting_insights_map_export:["insights.map.export","read"],accounting_insights_map_get:["insights.map.get","read"],accounting_insights_map_view:["insights.map.view","read"],accounting_insights_people_get:["insights.people.get","read"],accounting_insights_projects_get:["insights.projects.get","read"],accounting_insights_tax_get:["insights.tax.get","read"],accounting_intake_classify:["intake.classify","write"],accounting_intake_complete:["intake.complete","write"],accounting_intake_dismiss:["intake.dismiss","destructive"],accounting_intake_from_mail:["intake.fromMail","write"],accounting_intake_get:["intake.get","read"],accounting_intake_inline:["intake.inline","write"],accounting_intake_list:["intake.list","read"],accounting_intake_prepare:["intake.prepare","write"],accounting_intake_process:["intake.process","write"],accounting_intake_read:["intake.read","read"],accounting_investigations_questions_answer:["investigations.questions.answer","write"],accounting_investigations_questions_list:["investigations.questions.list","read"],accounting_investigations_review_run:["investigations.review.run","write"],accounting_investigations_run:["investigations.run","write"],accounting_investigator_accept:["investigator.accept","write"],accounting_investigator_consent_update:["investigator.consent.update","write"],accounting_investigator_dismiss:["investigator.dismiss","write"],accounting_investigator_financial_issue:["investigator.financialIssue","write"],accounting_investigator_for_entry:["investigator.forEntry","read"],accounting_investigator_overview:["investigator.overview","read"],accounting_investigator_run:["investigator.run","write"],accounting_investigator_settings_update:["investigator.settings.update","write"],accounting_invoices_approve:["invoices.approve","write"],accounting_invoices_archive:["invoices.archive","write"],accounting_invoices_automation_run:["invoices.automation.run","write"],accounting_invoices_correct_tax:["invoices.correctTax","write"],accounting_invoices_create:["invoices.create","write"],accounting_invoices_duplicate:["invoices.duplicate","write"],accounting_invoices_files_commit:["invoices.filesCommit","write"],accounting_invoices_files_extract:["invoices.filesExtract","read"],accounting_invoices_files_prepare:["invoices.filesPrepare","write"],accounting_invoices_get:["invoices.get","read"],accounting_invoices_import:["invoices.import","write"],accounting_invoices_issue:["invoices.issue","write"],accounting_invoices_last_for_party:["invoices.lastForParty","read"],accounting_invoices_list:["invoices.list","read"],accounting_invoices_mark_uncollectible:["invoices.markUncollectible","write"],accounting_invoices_numbering_preview:["invoices.numbering.preview","read"],accounting_invoices_pdf:["invoices.pdf","read"],accounting_invoices_plans_create:["invoices.plans.create","write"],accounting_invoices_preview:["invoices.preview","read"],accounting_invoices_project_suggestions:["invoices.projectSuggestions","read"],accounting_invoices_project_totals:["invoices.projectTotals","read"],accounting_invoices_record_payment:["invoices.recordPayment","write"],accounting_invoices_remind:["invoices.remind","external"],accounting_invoices_remove_payment:["invoices.removePayment","destructive"],accounting_invoices_schedule:["invoices.schedule","write"],accounting_invoices_schedules_cancel:["invoices.schedules.cancel","destructive"],accounting_invoices_schedules_create:["invoices.schedules.create","write"],accounting_invoices_schedules_generate:["invoices.schedules.generate","write"],accounting_invoices_schedules_list:["invoices.schedules.list","read"],accounting_invoices_schedules_pause:["invoices.schedules.pause","write"],accounting_invoices_schedules_resume:["invoices.schedules.resume","write"],accounting_invoices_schedules_update:["invoices.schedules.update","write"],accounting_invoices_send:["invoices.send","external"],accounting_invoices_set_project:["invoices.setProject","write"],accounting_invoices_summary:["invoices.summary","read"],accounting_invoices_tax_place:["invoices.taxPlace","read"],accounting_invoices_update:["invoices.update","write"],accounting_invoices_void:["invoices.void","destructive"],accounting_list_accounts:["accounts.list","read"],accounting_list_categories:["categories.list","read"],accounting_list_submissions:["inbox.list","read"],accounting_list_transactions:["transactions.list","read"],accounting_mail_activity_get:["mail.activity.get","read"],accounting_mail_approve:["mail.approve","write"],accounting_mail_ask_admin:["mail.askAdmin","external"],accounting_mail_attach_evidence:["mail.attachEvidence","write"],accounting_mail_download:["mail.download","read"],accounting_mail_drafts_create:["mail.drafts.create","write"],accounting_mail_drafts_update:["mail.drafts.update","write"],accounting_mail_fraud_decide:["mail.fraud.decide","write"],accounting_mail_fraud_rescan:["mail.fraud.rescan","write"],accounting_mail_get:["mail.get","read"],accounting_mail_inbound_addresses:["mail.inboundAddresses","read"],accounting_mail_list:["mail.list","read"],accounting_mail_purchase_candidates:["mail.purchaseCandidates","read"],accounting_mail_rerun:["mail.rerun","write"],accounting_mail_rerun_many:["mail.rerunMany","write"],accounting_mail_retry:["mail.retry","write"],accounting_mail_review_answer:["mail.review.answer","write"],accounting_mail_review_memory:["mail.review.memory","access"],accounting_mail_rules_list:["mail.rules.list","read"],accounting_mail_rules_save:["mail.rules.save","write"],accounting_mail_update:["mail.update","write"],accounting_mailboxes_connect_link:["mailboxes.connect.link","read"],accounting_mailboxes_connect_start:["mailboxes.connect.start","write"],accounting_mailboxes_disconnect:["mailboxes.disconnect","destructive"],accounting_mailboxes_list:["mailboxes.list","read"],accounting_mailboxes_scan:["mailboxes.scan","external"],accounting_mailboxes_update:["mailboxes.update","write"],accounting_match_transaction:["reconciliation.match","write"],accounting_matching_candidates:["matching.candidates","read"],accounting_matching_receipt_consolidation_candidates:["matching.receiptConsolidation.candidates","read"],accounting_matching_receipt_consolidation_confirm:["matching.receiptConsolidation.confirm","write"],accounting_matching_receipt_consolidation_preview:["matching.receiptConsolidation.preview","read"],accounting_matching_receipt_consolidation_undo:["matching.receiptConsolidation.undo","write"],accounting_matching_reject:["matching.reject","write"],accounting_matching_rerun_entry:["matching.rerunEntry","write"],accounting_matching_review:["matching.list","read"],accounting_matching_status:["matching.status","read"],accounting_members_list:["members.list","read"],accounting_members_update:["members.update","destructive"],accounting_memory_list:["memory.list","read"],accounting_memory_save:["memory.save","access"],accounting_merchants_confirm:["merchants.confirm","write"],accounting_merchants_enrich:["merchants.enrich","external"],accounting_merchants_get:["merchants.get","read"],accounting_merchants_list:["merchants.list","read"],accounting_merchants_settings_get:["merchants.settings.get","read"],accounting_merchants_settings_update:["merchants.settings.update","write"],accounting_notifications_checklist_dismiss:["notifications.checklist.dismiss","write"],accounting_notifications_checklist_list:["notifications.checklist.list","read"],accounting_notifications_comments_dismiss:["notifications.comments.dismiss","write"],accounting_notifications_comments_list:["notifications.comments.list","read"],accounting_notifications_joins_dismiss:["notifications.joins.dismiss","write"],accounting_notifications_joins_list:["notifications.joins.list","read"],accounting_notifications_preferences_get:["notifications.preferences.get","read"],accounting_notifications_preferences_update:["notifications.preferences.update","write"],accounting_notion_data_sources_get:["notion.dataSources.get","read"],accounting_notion_data_sources_query:["notion.dataSources.query","read"],accounting_notion_invoices_import:["notion.invoices.import","external"],accounting_notion_invoices_import_preview:["notion.invoices.importPreview","read"],accounting_notion_links_confirm:["notion.links.confirm","external"],accounting_notion_links_create:["notion.links.create","external"],accounting_notion_links_list:["notion.links.list","read"],accounting_notion_links_reject:["notion.links.reject","external"],accounting_notion_links_remove:["notion.links.remove","destructive"],accounting_notion_lookup:["notion.lookup","read"],accounting_notion_resolve_link:["notion.resolveLink","read"],accounting_notion_search:["notion.search","read"],accounting_notion_sync_run:["notion.sync.run","external"],accounting_onboarding_complete:["onboarding.complete","write"],accounting_onboarding_inbox_prompt:["onboarding.inboxPrompt","read"],accounting_onboarding_inbox_prompt_dismiss:["onboarding.inboxPrompt.dismiss","write"],accounting_onboarding_status:["onboarding.status","read"],accounting_parties_archive:["parties.archive","destructive"],accounting_parties_create:["parties.create","write"],accounting_parties_enrich:["parties.enrich","external"],accounting_parties_get:["parties.get","read"],accounting_parties_list:["parties.list","read"],accounting_parties_preview:["parties.preview","read"],accounting_parties_search:["parties.search","read"],accounting_parties_update:["parties.update","write"],accounting_payment_methods_archive:["paymentMethods.archive","destructive"],accounting_payment_methods_list:["paymentMethods.list","read"],accounting_payment_methods_save:["paymentMethods.save","write"],accounting_payment_methods_wise_options:["paymentMethods.wiseOptions","read"],accounting_places_search:["places.search","read"],accounting_places_settings_get:["places.settings.get","read"],accounting_places_settings_update:["places.settings.update","write"],accounting_platform_admin_access_requests_list:["platform.admin.accessRequests.list","read"],accounting_platform_admin_access_requests_review:["platform.admin.accessRequests.review","write"],accounting_platform_admin_experiments_list:["platform.admin.experiments.list","read"],accounting_platform_admin_experiments_update:["platform.admin.experiments.update","write"],accounting_platform_admin_organizations_get:["platform.admin.organizations.get","read"],accounting_platform_admin_organizations_update:["platform.admin.organizations.update","write"],accounting_platform_admin_overview:["platform.admin.overview","read"],accounting_platform_branding_confirm_logo:["platform.branding.confirmLogo","write"],accounting_platform_branding_logo:["platform.branding.logo","read"],accounting_platform_branding_prepare_logo:["platform.branding.prepareLogo","write"],accounting_platform_settings_get:["platform.settings.get","read"],accounting_platform_settings_update:["platform.settings.update","write"],accounting_prepare_upload:["uploads.prepare","write"],accounting_preview_bank_import:["imports.preview","read"],accounting_processing_status:["jobs.get","read"],accounting_proposals_create:["proposals.create","write"],accounting_proposals_decide:["proposals.decide","write"],accounting_proposals_get:["proposals.get","read"],accounting_proposals_list:["proposals.list","read"],accounting_receipt_tax_confirm:["receipt.tax.confirm","write"],accounting_reconciliation:["reconciliation.list","read"],accounting_reconciliation_reopen:["reconciliation.reopen","write"],accounting_recruiting_applications_assign:["recruiting.applications.assign","write"],accounting_recruiting_applications_convert:["recruiting.applications.convert","write"],accounting_recruiting_applications_create:["recruiting.applications.create","write"],accounting_recruiting_applications_get:["recruiting.applications.get","read"],accounting_recruiting_applications_list:["recruiting.applications.list","read"],accounting_recruiting_applications_move:["recruiting.applications.move","write"],accounting_recruiting_applications_reject:["recruiting.applications.reject","write"],accounting_recruiting_applications_restore:["recruiting.applications.restore","write"],accounting_recruiting_applications_resume:["recruiting.applications.resume","read"],accounting_recruiting_applications_summarize:["recruiting.applications.summarize","write"],accounting_recruiting_board_get:["recruiting.board.get","read"],accounting_recruiting_board_save:["recruiting.board.save","write"],accounting_recruiting_interviews_mine:["recruiting.interviews.mine","read"],accounting_recruiting_interviews_save:["recruiting.interviews.save","write"],accounting_recruiting_notes_add:["recruiting.notes.add","write"],accounting_recruiting_postings_get:["recruiting.postings.get","read"],accounting_recruiting_postings_list:["recruiting.postings.list","read"],accounting_recruiting_postings_rotate_link:["recruiting.postings.rotateLink","destructive"],accounting_recruiting_postings_save:["recruiting.postings.save","write"],accounting_recruiting_postings_status:["recruiting.postings.status","write"],accounting_recruiting_scorecards_submit:["recruiting.scorecards.submit","write"],accounting_recruiting_team_list:["recruiting.team.list","read"],accounting_reimbursements_approve:["reimbursements.approve","write"],accounting_reimbursements_bind_recipient:["reimbursements.bindRecipient","write"],accounting_reimbursements_candidates:["reimbursements.candidates","read"],accounting_reimbursements_claim_purchase:["reimbursements.claimPurchase","write"],accounting_reimbursements_complete_payment:["reimbursements.completePayment","write"],accounting_reimbursements_for_entry:["reimbursements.forEntry","read"],accounting_reimbursements_get:["reimbursements.get","read"],accounting_reimbursements_identify:["reimbursements.identify","write"],accounting_reimbursements_link:["reimbursements.link","write"],accounting_reimbursements_list:["reimbursements.list","read"],accounting_reimbursements_match_payment:["reimbursements.matchPayment","write"],accounting_reimbursements_prepare:["reimbursements.prepare","write"],accounting_reimbursements_recipients:["reimbursements.recipients","read"],accounting_reimbursements_record_payment:["reimbursements.recordPayment","write"],accounting_reimbursements_refresh_recipient:["reimbursements.refreshRecipient","write"],accounting_reimbursements_reject:["reimbursements.reject","write"],accounting_reimbursements_send:["reimbursements.send","external"],accounting_reimbursements_submit:["reimbursements.submit","write"],accounting_reimbursements_sync_payment:["reimbursements.syncPayment","external"],accounting_report:["reports.summary","read"],accounting_requests_create:["requests.create","external"],accounting_requests_list:["requests.list","read"],accounting_requests_people:["requests.people","read"],accounting_requests_update:["requests.update","write"],accounting_restore_bank_import:["transactions.restore","write"],accounting_retry_matching:["matching.request","write"],accounting_retry_processing:["submissions.retry","write"],accounting_reverse_bank_import:["transactions.reverse","destructive"],accounting_runs_get:["runs.get","read"],accounting_runs_list:["runs.list","read"],accounting_runs_trace:["runs.trace","read"],accounting_runs_workflows_catalog:["runs.workflows.catalog","read"],accounting_runs_workflows_get:["runs.workflows.get","read"],accounting_runs_workflows_list:["runs.workflows.list","read"],accounting_search_records:["entries.list","read"],accounting_senders_list:["senders.list","read"],accounting_senders_remove:["senders.remove","destructive"],accounting_senders_upsert:["senders.upsert","access"],accounting_settings_get:["settings.get","read"],accounting_settings_rotate_mailbox:["settings.rotateMailbox","destructive"],accounting_settings_update:["settings.update","write"],accounting_signing_envelopes_certificate:["signing.envelopes.certificate","read"],accounting_signing_envelopes_create_draft:["signing.envelopes.createDraft","write"],accounting_signing_envelopes_defaults:["signing.envelopes.defaults","read"],accounting_signing_envelopes_download:["signing.envelopes.download","read"],accounting_signing_envelopes_get:["signing.envelopes.get","read"],accounting_signing_envelopes_import_executed:["signing.envelopes.importExecuted","write"],accounting_signing_envelopes_keep:["signing.envelopes.keep","external"],accounting_signing_envelopes_list:["signing.envelopes.list","read"],accounting_signing_envelopes_prepare:["signing.envelopes.prepare","write"],accounting_signing_envelopes_remind:["signing.envelopes.remind","external"],accounting_signing_envelopes_resend:["signing.envelopes.resend","external"],accounting_signing_envelopes_retry_completion:["signing.envelopes.retryCompletion","write"],accounting_signing_envelopes_revise:["signing.envelopes.revise","destructive"],accounting_signing_envelopes_send:["signing.envelopes.send","external"],accounting_signing_envelopes_sign_as_member:["signing.envelopes.signAsMember","write"],accounting_signing_envelopes_update_draft:["signing.envelopes.updateDraft","write"],accounting_signing_envelopes_void:["signing.envelopes.void","destructive"],accounting_signing_events_list:["signing.events.list","read"],accounting_signing_files_confirm:["signing.files.confirm","write"],accounting_signing_files_from_google_docs:["signing.files.fromGoogleDocs","external"],accounting_signing_files_prepare:["signing.files.prepare","write"],accounting_signing_subjects_search:["signing.subjects.search","read"],accounting_signing_templates_archive:["signing.templates.archive","destructive"],accounting_signing_templates_create:["signing.templates.create","write"],accounting_signing_templates_get:["signing.templates.get","read"],accounting_signing_templates_list:["signing.templates.list","read"],accounting_signing_templates_preview:["signing.templates.preview","read"],accounting_signing_templates_publish:["signing.templates.publish","write"],accounting_signing_templates_update:["signing.templates.update","write"],accounting_split_categories:["reconciliation.split","write"],accounting_statements_download:["statements.download","read"],accounting_statements_lines:["statements.lines","read"],accounting_statements_list:["statements.list","read"],accounting_statements_review:["statements.review","write"],accounting_stripe_accept_change:["stripe.review.acceptChange","write"],accounting_stripe_classify:["stripe.review.resolve","write"],accounting_stripe_confirm_tax:["stripe.tax.confirm","write"],accounting_stripe_match_payout:["stripe.payouts.match","write"],accounting_stripe_payout:["stripe.payouts.get","read"],accounting_stripe_payouts:["stripe.payouts.list","read"],accounting_stripe_report:["stripe.report","read"],accounting_stripe_review:["stripe.review.list","read"],accounting_stripe_snapshot:["stripe.snapshots.download","read"],accounting_stripe_status:["stripe.status","read"],accounting_stripe_sync:["stripe.sync","external"],accounting_stripe_unmatch_payout:["stripe.payouts.unmatch","destructive"],accounting_stripe_year_download:["stripe.year.download","write"],accounting_stripe_year_get:["stripe.year.get","read"],accounting_submission_trip_suggestions:["submissions.tripSuggestions","read"],accounting_submissions_release:["submissions.release","write"],accounting_submit_emails:["emails.submitBatch","write"],accounting_subscriptions_duplicates_check:["subscriptions.duplicates.check","write"],accounting_subscriptions_list:["subscriptions.list","read"],accounting_subscriptions_merges_create:["subscriptions.merges.create","write"],accounting_subscriptions_merges_decide:["subscriptions.merges.decide","write"],accounting_subscriptions_merges_undo:["subscriptions.merges.undo","destructive"],accounting_subscriptions_save:["subscriptions.save","write"],accounting_subscriptions_suggest:["subscriptions.suggest","read"],accounting_summaries_get:["summaries.get","read"],accounting_summaries_update:["summaries.update","write"],accounting_tags_ai_list:["tags.ai.list","read"],accounting_tags_ai_run:["tags.ai.run","write"],accounting_tags_create:["tags.create","write"],accounting_tags_delete:["tags.delete","destructive"],accounting_tags_get:["tags.get","read"],accounting_tags_list:["tags.list","read"],accounting_tags_merge:["tags.merge","write"],accounting_tags_notion_link:["tags.notion.link","external"],accounting_tags_notion_preview:["tags.notion.preview","read"],accounting_tags_notion_resolve:["tags.notion.resolve","external"],accounting_tags_notion_sync:["tags.notion.sync","external"],accounting_tags_notion_unlink:["tags.notion.unlink","external"],accounting_tags_project_update:["tags.project.update","write"],accounting_tags_report:["tags.report","read"],accounting_tags_suggest:["tags.suggest","read"],accounting_tags_update:["tags.update","write"],accounting_tax_adjustments_update:["tax.adjustments.update","write"],accounting_tax_checks_update:["tax.checks.update","write"],accounting_tax_entries_review:["tax.entries.review","write"],accounting_tax_export:["tax.export","write"],accounting_tax_filings_get:["tax.filings.get","read"],accounting_tax_filings_update:["tax.filings.update","write"],accounting_tax_financial_counterparts_clear:["tax.financialCounterparts.clear","write"],accounting_tax_financial_counterparts_get:["tax.financialCounterparts.get","read"],accounting_tax_financial_counterparts_preview:["tax.financialCounterparts.preview","read"],accounting_tax_financial_counterparts_review:["tax.financialCounterparts.review","write"],accounting_tax_gifi_confirm:["tax.gifi.confirm","write"],accounting_tax_gifi_get:["tax.gifi.get","read"],accounting_tax_gifi_update:["tax.gifi.update","write"],accounting_tax_intercompany_counterparties_create:["tax.intercompanyCounterparties.create","write"],accounting_tax_intercompany_counterparties_list:["tax.intercompanyCounterparties.list","read"],accounting_tax_intercompany_obligations_list:["tax.intercompanyObligations.list","read"],accounting_tax_packages_download:["tax.packages.download","write"],accounting_tax_packages_list:["tax.packages.list","read"],accounting_tax_packages_request:["tax.packages.request","external"],accounting_tax_packages_revoke:["tax.packages.revoke","destructive"],accounting_tax_packages_share:["tax.packages.share","external"],accounting_tax_personal_expenses_confirm:["tax.personalExpenses.confirm","write"],accounting_tax_personal_expenses_export:["tax.personalExpenses.export","read"],accounting_tax_personal_expenses_get:["tax.personalExpenses.get","read"],accounting_tax_prep_overview:["tax.prep.overview","read"],accounting_tax_prizes_events_save:["tax.prizes.events.save","write"],accounting_tax_prizes_overview:["tax.prizes.overview","read"],accounting_tax_prizes_payouts_decide:["tax.prizes.payouts.decide","write"],accounting_tax_prizes_recipients_link:["tax.prizes.recipients.link","external"],accounting_tax_prizes_recipients_save:["tax.prizes.recipients.save","external"],accounting_tax_prizes_schedule:["tax.prizes.schedule","write"],accounting_tax_questions_answer:["tax.questions.answer","write"],accounting_tax_questions_list:["tax.questions.list","read"],accounting_tax_readiness:["tax.readiness","read"],accounting_tax_reports_download:["tax.reports.download","write"],accounting_tax_reports_overview:["tax.reports.overview","read"],accounting_tax_requests_add:["tax.requests.add","write"],accounting_tax_requests_extract:["tax.requests.extract","write"],accounting_tax_requests_list:["tax.requests.list","read"],accounting_tax_requests_update:["tax.requests.update","write"],accounting_tax_sources_confirm:["tax.sources.confirm","write"],accounting_tax_sources_prepare:["tax.sources.prepare","write"],accounting_tax_statements_acknowledge:["tax.statements.acknowledge","write"],accounting_tax_statements_overview:["tax.statements.overview","read"],accounting_tax_statements_pack:["tax.statements.pack","write"],accounting_tax_treatment_apply:["tax.treatment.apply","write"],accounting_tax_treatment_auto:["tax.treatment.auto","write"],accounting_tax_treatment_undo:["tax.treatment.undo","write"],accounting_team_invitations_link:["team.invitations.link","access"],accounting_team_invitations_resend:["team.invitations.resend","external"],accounting_team_invitations_revoke:["team.invitations.revoke","destructive"],accounting_team_invite:["team.invite","external"],accounting_team_list:["team.list","read"],accounting_team_members_remove:["team.members.remove","destructive"],accounting_transactions_documents_download:["transactions.documents.download","read"],accounting_transactions_get:["transactions.get","read"],accounting_trips_create:["trips.create","write"],accounting_trips_get:["trips.get","read"],accounting_trips_link_entry:["trips.linkEntry","write"],accounting_trips_list:["trips.list","read"],accounting_trips_unlink_entry:["trips.unlinkEntry","write"],accounting_trips_update:["trips.update","write"],accounting_unmatch_transaction:["reconciliation.unmatch","destructive"],accounting_update_category:["categories.update","write"],accounting_uploads_inline:["uploads.inline","write"],accounting_webhooks_deliveries_list:["webhooks.deliveries.list","read"],accounting_webhooks_deliveries_retry:["webhooks.deliveries.retry","external"],accounting_webhooks_deliveries_stats:["webhooks.deliveries.stats","read"],accounting_webhooks_endpoints_archive:["webhooks.endpoints.archive","destructive"],accounting_webhooks_endpoints_create:["webhooks.endpoints.create","access"],accounting_webhooks_endpoints_list:["webhooks.endpoints.list","read"],accounting_webhooks_endpoints_rotate_secret:["webhooks.endpoints.rotateSecret","destructive"],accounting_webhooks_endpoints_update:["webhooks.endpoints.update","write"],accounting_webhooks_events_catalog:["webhooks.events.catalog","read"],accounting_webhooks_test:["webhooks.test","external"],accounting_wise_profiles:["wise.profiles","read"],accounting_wise_receipts_decide:["wise.receipts.decide","write"],accounting_wise_receipts_review:["wise.receipts.review","read"],accounting_wise_receipts_status:["wise.receipts.status","read"],accounting_wise_receipts_sync:["wise.receipts.sync","external"],accounting_wise_status:["wise.status","read"],accounting_wise_sync:["wise.sync","external"]}});function R2A(A){let Q=Object.hasOwn(xH,A)?xH[A]:void 0;return Q?{action:Q[0],kind:Q[1]}:null}var g2A=W(()=>{$h()});var T2A=()=>{};function S2A(A){return Object.hasOwn(P2A,A)}function Uh(A,Q){let B=P2A[A],E=A.replace(/^accounting_/,"").replaceAll("_"," "),I=B?.[0]??`Running ${E}`,D=B?.[1]??`Ran ${E}`;if(Q==="output-error")return`Couldn't finish: ${I.charAt(0).toLowerCase()}${I.slice(1)}`;if(Q==="output-denied")return`Skipped: ${I.charAt(0).toLowerCase()}${I.slice(1)}`;return Q==="output-available"?D:`${I}…`}function UM(A){for(let Q=A.length-1;Q>=0;Q-=1){let B=A[Q].parts;for(let E=B.length-1;E>=0;E-=1){let I=B[E];if(I.type!=="dynamic-tool"||I.state!=="approval-requested")continue;let D=I.toolMetadata?.eve?.inputRequest;if(D)return{request:D,toolCallId:I.toolCallId}}}return null}function w2A(A){return A.toolName==="ask_question"||A.toolMetadata?.eve?.inputRequest!==void 0}function YM(A){let Q=A.options??[];if(A.allowFreeform===!1)return Q;return Q.filter((B)=>!oeA.test(B.label.trim()))}var P2A,oeA;var K$=W(()=>{P2A={accounting_get_record:["Reading the transaction","Read the transaction"],accounting_search_records:["Searching transactions","Searched transactions"],accounting_entries_context:["Checking the trip and place","Checked the trip and place"],accounting_autopilot_explain:["Reading the history","Read the history"],accounting_summaries_get:["Reading the purchase summary","Read the purchase summary"],accounting_investigator_for_entry:["Checking the investigation","Checked the investigation"],accounting_investigations_questions_list:["Checking open questions","Checked open questions"],accounting_matching_candidates:["Looking for matches","Looked for matches"],accounting_transactions_get:["Reading the bank line","Read the bank line"],accounting_list_transactions:["Searching bank lines","Searched bank lines"],accounting_list_categories:["Checking categories","Checked categories"],accounting_list_accounts:["Checking accounts","Checked accounts"],accounting_tags_list:["Checking projects","Checked projects"],accounting_tags_suggest:["Suggesting projects","Suggested projects"],accounting_merchants_get:["Reading the vendor","Read the vendor"],accounting_merchants_list:["Searching vendors","Searched vendors"],accounting_parties_search:["Searching customers and vendors","Searched customers and vendors"],accounting_contractors_list:["Searching contractors","Searched contractors"],accounting_contractors_payments_get:["Checking the contractor payment","Checked the contractor payment"],accounting_trips_list:["Checking trips","Checked trips"],accounting_trips_get:["Reading the trip","Read the trip"],accounting_reimbursements_for_entry:["Checking the reimbursement","Checked the reimbursement"],accounting_mail_get:["Reading the email","Read the email"],accounting_mail_list:["Searching email","Searched email"],accounting_mail_activity_get:["Reading the email's history","Read the email's history"],accounting_mail_purchase_candidates:["Looking for the purchase","Looked for the purchase"],accounting_get_submission:["Reading the receipt upload","Read the receipt upload"],accounting_list_submissions:["Searching receipts","Searched receipts"],accounting_memory_list:["Checking what Oatmilk remembers","Checked what Oatmilk remembers"],accounting_edit_record:["Updating the transaction","Updated the transaction"],accounting_entries_tags_set:["Updating projects","Updated projects"],accounting_entries_hold_set:["Marking the hold","Marked the hold"],accounting_attach_receipt:["Attaching the receipt","Attached the receipt"],accounting_match_transaction:["Matching the bank line","Matched the bank line"],accounting_split_categories:["Splitting categories","Split categories"],accounting_receipt_tax_confirm:["Confirming the tax","Confirmed the tax"],accounting_autopilot_classify:["Asking Autopilot","Asked Autopilot"],accounting_create_category:["Creating a category","Created a category"],accounting_tags_create:["Creating a project","Created a project"],accounting_trips_create:["Creating a trip","Created a trip"],accounting_trips_link_entry:["Adding it to the trip","Added it to the trip"],accounting_reimbursements_submit:["Submitting the reimbursement","Submitted the reimbursement"],accounting_contractors_payments_link:["Linking the contractor","Linked the contractor"],accounting_merchants_confirm:["Updating the vendor","Updated the vendor"],accounting_investigations_questions_answer:["Answering the question","Answered the question"],accounting_mail_update:["Updating the email","Updated the email"],accounting_mail_attach_evidence:["Attaching the email","Attached the email"],accounting_mail_drafts_create:["Drafting it for the books","Drafted it for the books"],accounting_mail_drafts_update:["Fixing the draft","Fixed the draft"],accounting_mail_approve:["Adding it to the books","Added it to the books"],accounting_mail_review_answer:["Answering Oatmilk's question","Answered Oatmilk's question"],accounting_mail_retry:["Processing the email again","Processing the email again"],accounting_intake_from_mail:["Filing the attachment","Filed the attachment"],accounting_retry_processing:["Reading the receipt again","Reading the receipt again"],accounting_memory_save:["Remembering this","Remembered this"],get_item:["Reading the latest details","Read the latest details"],read_attachment:["Reading the file","Read the file"]};oeA=/^(other|something else|none of these|not sure|something different)\b/i});var v2A=()=>{};var avQ;var yH=W(()=>{v2A();avQ=Object.freeze({data:void 0,hasData:!1,at:0,fetching:!1,error:void 0})});var Yh=()=>{};function y2A(A,Q){if(S2A(A))return Uh(A,Q);let B=eeA[A];if(B){if(Q==="output-error")return`Couldn't finish: ${B[0].charAt(0).toLowerCase()}${B[0].slice(1)}`;if(Q==="output-denied")return`Not done: ${B[0].charAt(0).toLowerCase()}${B[0].slice(1)}`;return Q==="output-available"?B[1]:`${B[0]}…`}let E=A.split("_").filter((U)=>U&&!teA.has(U)),I=-1;for(let U=E.length-1;U>=0&&I<0;U-=1)if(E[U]in b2A)I=U;let D=I>=0?E[I]:"run",J=E.filter((U,Y)=>Y!==I).join(" ")||"the tool",G=`${b2A[D]} ${J}`;if(Q==="output-error")return`Couldn't finish: ${G.charAt(0).toLowerCase()}${G.slice(1)}`;if(Q==="output-denied")return`Not done: ${G.charAt(0).toLowerCase()}${G.slice(1)}`;return Q==="output-available"?`${x2A[D]} ${J}`:`${G}…`}function QAQ(A){let Q=A.toolName==="attachments"?A.input?.action:void 0,B=AAQ[A.toolName==="attachments"?`attachments:${typeof Q==="string"?Q:"open"}`:A.toolName];if(!B)return;if(A.state==="output-error"||A.state==="output-available"&&Boolean(A.output?.error))return`Couldn't finish: ${B[0].charAt(0).toLowerCase()}${B[0].slice(1)}`;if(A.state==="output-denied")return`Not done: ${B[0].charAt(0).toLowerCase()}${B[0].slice(1)}`;return A.state==="output-available"?B[1]:`${B[0]}…`}function YG(A){if(A.toolName===_4)return A.state==="output-available"||A.state==="output-denied"?null:"Looking that up…";if(A.toolName===M2A){let E=A.input?.action==="read";if(A.state==="output-error")return"Couldn't read the developer docs";if(A.state==="output-available"||A.state==="output-denied")return E?"Read the developer docs":null;return E?"Reading the developer docs…":"Searching the developer docs…"}if(A.toolName===Jh){let E=A.input,I=A.state==="output-available"?$G(A.output):null;if(E?.action!=="open")return A.state==="output-available"?null:"Finding the page…";if(I)return I.open==="now"?`Opened ${I.label}`:null;if(A.state==="output-error")return"Couldn't open that page";return`Opening ${typeof E.label==="string"?E.label:"the page"}…`}let Q=QAQ(A);if(Q!==void 0)return Q;let B=CM(A.toolName,A.input);if(B)return y2A(B.name,A.state);return Uh(A.toolName,A.state)}function BAQ(A){if(A.endsWith("ies"))return`${A.slice(0,-3)}y`;if(/(ses|xes|ches|shes)$/.test(A))return A.slice(0,-2);return A.endsWith("s")&&!A.endsWith("ss")?A.slice(0,-1):A}function O8(A,Q){let B=CM(A.toolName,A.input);if(!B)return Q;let E=y2A(B.name,"output-available"),I=E.split(" ")[0],D=Object.entries(x2A).find(([,X])=>X===I)?.[0],J=E.slice(I.length+1),G=J.split(" "),U=typeof B.input.id==="string"&&G.length>0?`this ${[...G.slice(0,-1),BAQ(G.at(-1))].join(" ")}`:J,Y=D?`${D} ${U}`:E,H=["name","title","subject","displayName","merchant","label"].map((X)=>B.input[X]).find((X)=>typeof X==="string"&&X.trim().length>0);return`Allow Oatmilk to ${Y}${H?` (${H.trim().slice(0,60)})`:""}?`}function IAQ(A){return A&&typeof A==="object"&&!Array.isArray(A)?A:null}function f2A(A,Q){for(let B=A.length-1;B>=0;B-=1){let E=A[B];if(E.type!=="actions.requested")continue;let I=E.data.actions.find((D)=>D.kind==="tool-call"&&D.callId===Q);if(I&&I.kind==="tool-call")return{toolName:I.toolName,input:I.input}}return null}function h2A(A,Q){if(A.type!=="action.result"||A.data.status!=="completed")return null;let B=A.data.result;if(B.kind!=="tool-result"||B.isError===!0)return null;let E=f2A(Q,B.callId),I=E?CM(E.toolName,E.input):null,D=I?R2A(I.name):null;if(!I||!D||D.kind==="read")return null;return{tool:I.name,action:D.action,input:I.input}}function u2A(A,Q){if(A.type!=="action.result"||A.data.status!=="completed")return null;let B=A.data.result;if(B.kind!=="tool-result"||B.isError===!0)return null;let E=f2A(Q,B.callId);if(E?.toolName!==Jh||IAQ(E.input)?.action!=="open")return null;return $G(B.output)}function EAQ(A,Q){if(Q?.get("invoice")||/\/finance\/invoices\/[^/]+\/edit$/.test(A))return["Summarize this invoice","Which project is this for?","Has this customer paid on time before?"];if(Q?.get("party")||Q?.get("account"))return["What does this customer owe us?","How fast do they usually pay?","Look this customer up online"];if(A==="/finance/invoices/new")return["Draft an invoice like the last one","Who did we invoice last month?","Which payment terms do we usually use?"];let B=Q?.get("view");if(B==="customers"||B==="vendors"||B==="accounts"||B==="archived-accounts")return["Who owes us the most?","Which customers pay late?","Look up our newest customer online"];if(B==="scheduled")return["What goes out this week?","Which recurring invoices need approval?","Pause a recurring invoice"];let E=Q?.get("status");if(E==="needs_action")return["What needs me first?","Approve what's ready to go","Remind customers who are late"];if(E==="overdue"||E==="open")return["Who owes us the most?","Draft reminders for late invoices","How much is overdue by currency?"];if(E==="archived")return["Find an archived invoice","Restore an invoice","Which archived invoices were paid?"];return["Which invoices are overdue?","Tie invoices to projects","Who owes us the most?"]}function DAQ(A){let Q=A?.get("view");if(Q==="records")return["Which tax papers do we keep?","Find last year's tax return","What is this page for?"];if(Q==="workpaper")return["Explain this workpaper","Which records still need a look?",LD];let B=A?.get("step")??"",E=Object.hasOwn(k2A,B)?k2A[B]:null;if(E)return[Kh,...E];return A?.get("kind")==="gst_hst"?[LD,Kh,_8]:[LD,"What does my accountant still need?",Kh]}function JAQ(A,Q){if(Q?.get("item"))return["What do I need to do this?","Mark this done","Who should own this?"];if(A.startsWith("/calendar"))return["What's due this month?","What's coming up next month?","Which deadlines are overdue?"];return["What should I do first?","What's due in the next 30 days?","Assign the overdue items to me"]}function KM(A,Q,B){if(Q==="accountant"){if(A==="/accountant/map")return["Find transactions on this map","What's in this area?","Download this map as an image"];if(A.startsWith("/accountant/access"))return["What access do I have?","When does my access end?","How do I ask for more access?"];if(A.startsWith("/accountant/transactions")||A.startsWith("/accountant/receipts"))return["Explain this record","Find a transaction","Which receipts are missing?"];if(A.startsWith("/accountant/financial-statements"))return["Explain the income statement","Why doesn't the trial balance balance?","Download the balance sheet"];if(A.startsWith("/accountant/reports"))return["Make the year-end package","Summarize Stripe for the year","Which records need review?"];return["What is missing for year-end?","Find a transaction","What can you help me with?"]}if(A.startsWith("/developers"))return[Q==="admin"?"How do I verify webhook signatures?":"How do I make my first API request?","Why did my last API request fail?","Which permissions does my script need?"];if(Q==="contributor")return["Which of my purchases need a receipt?","Help me get paid back for something","What can I do here?"];if(A.startsWith("/finance/transactions")||A.startsWith("/finance/reconcile"))return["What needs me here?","Categorize the ones Autopilot is unsure about","Find a transaction"];if(A.startsWith("/finance/financial-statements"))return["Send everything to my accountant","Explain the income statement","Download the balance sheet for last quarter"];if(A.startsWith("/inbox")&&B?.get("view")==="ai")return Q==="admin"?["Read our email with GLM 5.3 Flash at high effort","Which models read our email?","Put the inbox back on the recommended models"]:["Which models read our email?","What does effort change?","What does the second opinion do?"];if(A.startsWith("/inbox"))return["What came in that needs me?","Which emails are quarantined and why?","Find a receipt"];if(A.startsWith("/finance/invoices"))return EAQ(A,B);if(A==="/finance/tax")return DAQ(B);if(A.startsWith("/finance/tax"))return["Which company details does tax need?",LD,"What can you do here?"];if(A.startsWith("/checklist")||A.startsWith("/calendar"))return JAQ(A,B);if(A.startsWith("/people/contractors"))return["Whose timesheets need review?","Who's due a payout?","Find a contractor"];if(A.startsWith("/legal"))return["Which agreements are waiting on signatures?","Find an agreement","Send an agreement for signature"];if(A==="/insights"&&B?.get("view")==="map")return["Show our trips on this map","What's in this area?","Download this map as an image"];if(A.startsWith("/insights")||A.startsWith("/finance/reports"))return["How did we spend last month?","What changed since last quarter?","Explain this page"];if(A.startsWith("/settings"))return["Who has access to this company?","How do receipts get into Oatmilk?","Take me to bank connections"];return["What needs me today?","Take me to receipt matching","What can you do here?"]}var b2A,x2A,teA,eeA,AAQ,Kh="What does this step mean?",LD="What's left before I can file?",_8="Do this step with me",k2A;var L8=W(()=>{l1();g2A();T2A();K$();yH();Yh();b2A={list:"Listing",get:"Reading",search:"Searching",create:"Creating",update:"Updating",set:"Setting",delete:"Deleting",remove:"Removing",send:"Sending",link:"Linking",unlink:"Unlinking",approve:"Approving",archive:"Archiving",match:"Matching",start:"Starting",run:"Running",answer:"Answering",submit:"Submitting",save:"Saving",review:"Reviewing",retry:"Retrying",void:"Voiding",invite:"Inviting",import:"Importing",export:"Exporting",confirm:"Confirming",classify:"Classifying",explain:"Explaining",status:"Checking",overview:"Checking",report:"Reporting on",revoke:"Revoking",restore:"Restoring",prepare:"Preparing",remind:"Reminding",resend:"Resending",decide:"Deciding on",split:"Splitting",unmatch:"Unmatching",reopen:"Reopening",close:"Closing",download:"Getting",preview:"Previewing",commit:"Importing",suggest:"Suggesting",candidates:"Finding"},x2A={list:"Listed",get:"Read",search:"Searched",create:"Created",update:"Updated",set:"Set",delete:"Deleted",remove:"Removed",send:"Sent",link:"Linked",unlink:"Unlinked",approve:"Approved",archive:"Archived",match:"Matched",start:"Started",run:"Ran",answer:"Answered",submit:"Submitted",save:"Saved",review:"Reviewed",retry:"Retried",void:"Voided",invite:"Invited",import:"Imported",export:"Exported",confirm:"Confirmed",classify:"Classified",explain:"Explained",status:"Checked",overview:"Checked",report:"Reported on",revoke:"Revoked",restore:"Restored",prepare:"Prepared",remind:"Reminded",resend:"Resent",decide:"Decided on",split:"Split",unmatch:"Unmatched",reopen:"Reopened",close:"Closed",download:"Got",preview:"Previewed",commit:"Imported",suggest:"Suggested",candidates:"Found"},teA=new Set(["accounting","ops","v1"]),eeA={accounting_bulk_categorize:["Categorizing transactions","Categorized transactions"],accounting_attention_list:["Checking what needs you","Checked what needs you"],accounting_attention_mine:["Checking your purchases","Checked your purchases"],accounting_autopilot_status:["Checking Autopilot","Checked Autopilot"],accounting_report:["Adding up the totals","Added up the totals"],accounting_insights_finance_get:["Reading finance insights","Read finance insights"],accounting_insights_finance_trends:["Reading spending trends","Read spending trends"],accounting_insights_people_get:["Reading people insights","Read people insights"],accounting_insights_projects_get:["Reading project insights","Read project insights"],accounting_insights_tax_get:["Reading tax insights","Read tax insights"],accounting_tax_prep_overview:["Checking your tax steps","Checked your tax steps"],accounting_tax_readiness:["Checking the tax workpaper","Checked the tax workpaper"],accounting_tax_financial_counterparts_get:["Reading the transfer review","Read the transfer review"],accounting_tax_financial_counterparts_preview:["Checking what the transfer will change","Checked what the transfer will change"],accounting_tax_financial_counterparts_review:["Saving the transfer review","Saved the transfer review"],accounting_tax_financial_counterparts_clear:["Removing the transfer review","Removed the transfer review"],accounting_tax_intercompany_counterparties_list:["Reading saved company names","Read saved company names"],accounting_tax_intercompany_counterparties_create:["Saving the other company's name","Saved the other company's name"],accounting_tax_intercompany_obligations_list:["Checking what is still owed","Checked what is still owed"],accounting_matching_receipt_consolidation_candidates:["Finding saved payments for the receipt","Found saved payments for the receipt"],accounting_matching_receipt_consolidation_preview:["Checking the receipt against the saved payment","Checked the receipt against the saved payment"],accounting_matching_receipt_consolidation_confirm:["Linking the receipt to the saved payment","Linked the receipt to the saved payment"],accounting_matching_receipt_consolidation_undo:["Undoing the receipt link","Undid the receipt link"],accounting_investigator_financial_issue:["Investigating the financial issue","Investigated the financial issue"],accounting_tax_sources_prepare:["Getting ready to add a tax paper","Got ready to add a tax paper"],accounting_tax_sources_confirm:["Saving the tax paper","Saved the tax paper"],accounting_tax_entries_review:["Saving the sales tax check","Saved the sales tax check"],accounting_tax_treatment_auto:["Sorting the sales tax","Sorted the sales tax"],accounting_tax_treatment_apply:["Confirming the sales tax for a group","Confirmed the sales tax for a group"],accounting_tax_treatment_undo:["Undoing a sales tax choice","Undid a sales tax choice"],accounting_tax_adjustments_update:["Saving your GST/HST adjustments","Saved your GST/HST adjustments"],accounting_tax_checks_update:["Saving your answer","Saved your answer"],accounting_tax_export:["Making the year-end package","Made the year-end package"],accounting_tax_gifi_get:["Reading your tax form lines","Read your tax form lines"],accounting_tax_gifi_update:["Matching categories to the tax form","Matched categories to the tax form"],accounting_tax_gifi_confirm:["Confirming the tax form lines","Confirmed the tax form lines"],accounting_tax_questions_list:["Reading the year-end questions","Read the year-end questions"],accounting_tax_questions_answer:["Saving your answer","Saved your answer"],accounting_tax_requests_list:["Checking your accountant's list","Checked your accountant's list"],accounting_tax_requests_extract:["Reading your accountant's email","Read your accountant's email"],accounting_tax_requests_add:["Adding to your accountant's list","Added to your accountant's list"],accounting_tax_requests_update:["Updating your accountant's list","Updated your accountant's list"],accounting_tax_statements_overview:["Checking your statements","Checked your statements"],accounting_tax_statements_pack:["Packing your statements","Packed your statements"],accounting_tax_statements_acknowledge:["Noting a statement gap for your accountant","Noted a statement gap for your accountant"],accounting_tax_personal_expenses_get:["Checking costs paid personally","Checked costs paid personally"],accounting_tax_personal_expenses_confirm:["Saving your answer about personal costs","Saved your answer about personal costs"],accounting_tax_personal_expenses_export:["Making the personal costs list","Made the personal costs list"],accounting_tax_prizes_overview:["Checking prize payouts","Checked prize payouts"],accounting_tax_prizes_events_save:["Saving the prize event","Saved the prize event"],accounting_tax_prizes_payouts_decide:["Saving the prize payout","Saved the prize payout"],accounting_tax_prizes_recipients_save:["Saving the winner","Saved the winner"],accounting_tax_prizes_recipients_link:["Updating the winner's link","Updated the winner's link"],accounting_tax_prizes_schedule:["Making the T4A list","Made the T4A list"],accounting_tax_reports_overview:["Reading the reports for your accountant","Read the reports for your accountant"],accounting_tax_reports_download:["Making the report for your accountant","Made the report for your accountant"],accounting_stripe_year_get:["Reading Stripe for the year","Read Stripe for the year"],accounting_stripe_year_download:["Making the Stripe download for the year","Made the Stripe download for the year"],accounting_tax_filings_get:["Checking what's left to file","Checked what's left to file"],accounting_tax_filings_update:["Recording what you filed","Recorded what you filed"],accounting_company_get:["Reading your company details","Read your company details"],accounting_company_update:["Updating your company details","Updated your company details"],accounting_tax_packages_list:["Checking the year-end packages","Checked the year-end packages"],accounting_tax_packages_request:["Putting everything in one ZIP","Started putting everything in one ZIP"],accounting_tax_packages_share:["Sending the package","Sent the package"],accounting_tax_packages_revoke:["Turning off the package links","Turned off the package links"],accounting_tax_packages_download:["Getting the package download","Got the package download"],accounting_company_shareholders_get:["Reading the shareholder register","Read the shareholder register"],accounting_company_shareholders_update:["Updating the shareholder register","Updated the shareholder register"],accounting_company_shareholders_tax_number:["Saving a shareholder's tax number","Saved a shareholder's tax number"],accounting_company_shareholders_export:["Making the register with tax numbers","Made the register with tax numbers"],accounting_company_facts_review:["Reading what your documents say about the company","Read what your documents say about the company"],accounting_company_facts_apply:["Saving company details from your documents","Saved company details from your documents"],accounting_handoff_get:["Reading the accountant hand-off","Read the accountant hand-off"],accounting_handoff_update:["Saving the accountant hand-off","Saved the accountant hand-off"],accounting_handoff_export:["Making the accountant package","Made the accountant package"],accounting_accountants_invite:["Inviting your accountant","Invited your accountant"],accounting_close_period:["Locking an account's records","Locked an account's records"],accounting_contractor_ops_directory_list:["Listing contractors","Listed contractors"],accounting_documents_content_get:["Reading the document","Read the document"],accounting_documents_content_edit:["Editing the document","Edited the document"],accounting_signing_templates_publish:["Publishing the template","Published the template"],accounting_list_submissions:["Searching receipts","Searched receipts"],accounting_intake_get:["Checking your file","Checked your file"],accounting_intake_read:["Reading your file","Read your file"],accounting_intake_classify:["Working out what your file is","Worked out what your file is"],accounting_intake_process:["Putting your file where it goes","Put your file where it goes"]};AAQ={"attachments:open":["Opening your files","Opened your files"],"attachments:view":["Looking at your file","Looked at your file"],"attachments:add":["Adding your file to Oatmilk","Added your file to Oatmilk"],bash:["Working with your files","Worked with your files"],read_file:["Reading a file","Read a file"],write_file:["Writing a file","Wrote a file"]};k2A={accountant:["What does my accountant still need?","Turn their email into a to-do list"],company:["Which details are missing?",_8],bank:["Which bank records are missing?",_8],statements:["Which statements are missing?",_8],review:["Which records need a look?",_8],records:["Which records need a look?",_8],tax_records:["Which records need a sales tax check?",_8],close:["Is it safe to lock the records?",LD],questions:["Answer the questions with me",LD],personal:["Did anyone pay with their own money?",_8],prizes:["Which winners need a T4A slip?",_8],gifi:["Match the categories with me",LD],handoff:["Make the year-end package","Write a note to my accountant"],adjustments:[_8,LD],return:["Explain these GST/HST numbers",LD]}});function GAQ(A){return m2A.test(A)}function fH(A){let Q=m2A.exec(A);if(!Q)throw Error(`Expected a six-digit hex color such as #1a2b3c, got "${A}"`);let B=Q[1];return[parseInt(B.slice(0,2),16),parseInt(B.slice(2,4),16),parseInt(B.slice(4,6),16)]}function hH(A){return`#${A.map((Q)=>Math.round(Math.min(255,Math.max(0,Q))).toString(16).padStart(2,"0")).join("")}`}function XQ(A,Q,B){let E=fH(A),I=fH(Q);return hH([E[0]+(I[0]-E[0])*B,E[1]+(I[1]-E[1])*B,E[2]+(I[2]-E[2])*B])}function Hh(A){let Q=A/255;return Q<=0.04045?Q/12.92:((Q+0.055)/1.055)**2.4}function H$(A){let[Q,B,E]=fH(A);return 0.2126*Hh(Q)+0.7152*Hh(B)+0.0722*Hh(E)}function rE(A,Q){let[B,E]=[H$(A),H$(Q)].sort((I,D)=>D-I);return(B+0.05)/(E+0.05)}function c2A(A,Q){return Q.reduce((B,E)=>rE(E,A)>rE(B,A)?E:B)}function W8(A,Q,B,E){for(let I=0;I<=40;I+=1){let D=XQ(A,E,I/40);if(Q.every((J)=>rE(D,J)>=B))return D}return E}function Xh(A){let Q=fH(A),B=Math.max(...Q);if(B===0)return"#ffffff";return hH([Q[0]*255/B,Q[1]*255/B,Q[2]*255/B])}function wU(A,Q,B,E=4.5){let I=(D)=>Q.every((J)=>rE(D,J)>=E);if(I(A))return A;if(H$(B)>0.5){let D=W8(A,Q,E,Xh(A));if(I(D))return D;return W8(D,Q,E,B)}return W8(A,Q,E,B)}function l2A(A,Q){let[B,E,I]=fH(A);return`rgb(${B} ${E} ${I} / ${Math.round(Q*100)}%)`}function CAQ(A,Q,B){let E=Q*Math.cos(B*Math.PI/180),I=Q*Math.sin(B*Math.PI/180),D=(A+0.3963377774*E+0.2158037573*I)**3,J=(A-0.1055613458*E-0.0638541728*I)**3,G=(A-0.0894841775*E-1.291485548*I)**3,U=[4.0767416621*D-3.3077115913*J+0.2309699292*G,-1.2684380046*D+2.6097574011*J-0.3413193965*G,-0.0041960863*D-0.7034186147*J+1.707614701*G],Y=(H)=>{let X=Math.min(1,Math.max(0,H));return 255*(X<=0.0031308?12.92*X:1.055*X**0.4166666666666667-0.055)};return hH([Y(U[0]),Y(U[1]),Y(U[2])])}function $AQ(A,Q,B){let E=(1-Math.abs(2*B-1))*Q,I=(A%360+360)%360/60,D=E*(1-Math.abs(I%2-1)),[J,G,U]=I<1?[E,D,0]:I<2?[D,E,0]:I<3?[0,E,D]:I<4?[0,D,E]:I<5?[D,0,E]:[E,0,D],Y=B-E/2;return hH([(J+Y)*255,(G+Y)*255,(U+Y)*255])}function SU(A,Q=1){return A.endsWith("%")?parseFloat(A)/100*Q:parseFloat(A)}function Zh(A,Q="#ffffff"){let B=A.trim().toLowerCase();if(/^#[0-9a-f]{3}$/.test(B))return`#${[...B.slice(1)].map((H)=>H+H).join("")}`;if(GAQ(B))return B;let E=/^(oklch|rgba?|hsla?)?\(?\s*([^)]*?)\s*\)?$/.exec(B);if(!E)throw Error(`Unsupported color "${A}"`);let[I,D]=E[2].split("/").map((H)=>H.trim()),J=I.split(/[\s,]+/).filter(Boolean);if(J.length!==3)throw Error(`Unsupported color "${A}"`);let G=E[1]??"hsl",U=G==="oklch"?CAQ(SU(J[0]),SU(J[1],0.4),parseFloat(J[2])):G.startsWith("rgb")?hH(J.map((H)=>SU(H,255))):$AQ(parseFloat(J[0]),SU(J[1]),SU(J[2])),Y=D===void 0?1:SU(D);return Y>=1?U:XQ(Q,U,Y)}var m2A;var HM=W(()=>{m2A=/^#([0-9a-f]{6})$/i});function bU(A,Q){return Q.find((B)=>rE(B,A)>=4.5)??c2A(A,Q)}function xU(A){let Q=A.scheme==="dark",B=Q?i2A:d2A,{background:E,foreground:I,primary:D}=A,J=A.card??(Q?XQ(E,I,0.04):XQ(E,"#ffffff",0.75)),G=A.muted??XQ(E,I,Q?0.05:0.035),U=A.secondary??XQ(E,I,Q?0.09:0.06),Y=A.accent??XQ(E,I,Q?0.11:0.075),H=[E,J,G],X=(w)=>wU(w,H,I),N=A.primaryForeground??bU(D,[E,I,...vU]),z=A.highlight??(Q?XQ(E,D,0.3):XQ(D,"#ffffff",0.7)),F=X(A.ring??D),V=A.sidebar??(Q?XQ(E,"#000000",0.3):XQ(E,I,0.03)),O=A.sidebarAccent??XQ(V,I,Q?0.1:0.07),j=bU(O,[I,E,...vU]),b=Object.fromEntries(UAQ.map((w)=>[w,A.tokens?.[w]??X(A[w]??B[w])])),x=Object.fromEntries(YAQ.map((w)=>[w,X(B[w])])),v={background:E,foreground:I,card:J,primary:D,"primary-foreground":N,"primary-ink":X(A.primaryInk??D),secondary:U,"secondary-foreground":bU(U,[I,E,...vU]),muted:G,"muted-foreground":W8(A.mutedForeground??XQ(I,E,0.42),[...H,Y],4.5,I),accent:Y,"accent-foreground":bU(Y,[I,E,...vU]),...b,"destructive-foreground":bU(b.destructive,[E,I,...vU]),border:A.border??XQ(E,I,Q?0.14:0.11),input:A.input??XQ(E,I,Q?0.28:0.3),ring:F,highlight:z,"highlight-foreground":bU(z,[I,E,...vU]),overlay:Q?"rgb(0 0 0 / 60%)":l2A(XQ(I,"#000000",0.4),0.2),"chart-1":D,"chart-2":XQ(I,E,0.45),"chart-3":b.info,"chart-4":b.warning,"chart-5":b.success,sidebar:V,"sidebar-foreground":W8(XQ(I,V,0.15),[V],4.5,I),"sidebar-primary":D,"sidebar-primary-foreground":N,"sidebar-accent":O,"sidebar-accent-foreground":j,"sidebar-border":XQ(V,I,Q?0.1:0.09),"sidebar-ring":F,...x};return{id:A.id,name:A.name,description:A.description,scheme:A.scheme,special:!0,palette:A.palette,tokens:HAQ({...v,...A.tokens})}}function KAQ(A,Q){let B=(D)=>Q.every(([J,G])=>rE(D,J)>=G);if(B(A))return A;let E=Q.every(([D])=>rE("#000000",D)>=rE("#ffffff",D)),I=A;for(let D of E?["#000000"]:[Xh(A),"#ffffff"]){for(let J=1;J<=40;J+=1){let G=XQ(I,D,J/40);if(B(G))return G}I=D}return E?"#000000":"#ffffff"}function HAQ(A){let Q={...A};for(let B of[...new Set(p2A.map(([E])=>E))]){let E=p2A.filter(([I])=>I===B).map(([,I,D])=>[Q[I],D]);Q[B]=KAQ(Q[B],E)}return Q}function ZAQ(A){return Object.fromEntries([...A.matchAll(/--([a-z0-9-]+)\s*:\s*([^;]+);/gi)].map((Q)=>[Q[1].toLowerCase(),Q[2].trim()]))}function kU(A){let Q=ZAQ(A.css);for(let X of["background","foreground","primary"])if(!Q[X])throw Error(`The ${A.name} export has no --${X}`);let B=Zh(Q.background),E=Object.fromEntries(XAQ.filter((X)=>Q[X]).map((X)=>[X,Zh(Q[X],B)])),{foreground:I,primary:D}=E,J=E.card??B,G=(X)=>X!==void 0&&rE(X,B)>=4.5&&rE(X,J)>=4.5,U=E["primary-foreground"],Y=G(D)?D:G(U)?U:void 0,H=E.input&&rE(E.input,B)<1.8?W8(E.input,[B],1.8,I):E.input;return xU({id:A.id,name:A.name,description:A.description,scheme:A.scheme,palette:A.palette??[B,D,E["sidebar-primary"]??D,E["chart-2"]??D,I].filter((X,N,z)=>z.indexOf(X)===N),background:B,foreground:I,primary:D,primaryForeground:U,primaryInk:Y,card:E.card,secondary:E.secondary,accent:E.accent,muted:E.muted,mutedForeground:E["muted-foreground"],border:E.border,input:H,ring:E.ring,sidebar:E.sidebar,sidebarAccent:E["sidebar-accent"],destructive:E.destructive,tokens:H?{...E,input:H}:E})}function X$(A){return Nh.find((Q)=>Q.id===A)}var d2A,i2A,vU,UAQ,YAQ,p2A,XAQ,XM,uH,NAQ,Nh;var zh=W(()=>{HM();d2A={background:"#ffffff",foreground:"#222321",card:"#ffffff",primary:"#262923","primary-foreground":"#ffffff","primary-ink":"#262923",secondary:"#f1f1ee","secondary-foreground":"#222321",muted:"#f6f6f3","muted-foreground":"#656660",accent:"#eeeee9","accent-foreground":"#222321",destructive:"#a52d2d","destructive-foreground":"#ffffff",border:"#e3e3df",input:"#b9bbb3",ring:"#3457a5",success:"#296844",warning:"#805400",info:"#315f9a",highlight:"#edf26a","highlight-foreground":"#222321",overlay:"rgb(20 22 20 / 18%)","chart-1":"#262923","chart-2":"#6b6c66","chart-3":"#315f9a","chart-4":"#805400","chart-5":"#296844",sidebar:"#f4f3f1","sidebar-foreground":"#44453f","sidebar-primary":"#222321","sidebar-primary-foreground":"#ffffff","sidebar-accent":"#e9e8e4","sidebar-accent-foreground":"#222321","sidebar-border":"#e3e3df","sidebar-ring":"#3457a5","tag-gray":"#6b6c66","tag-red":"#c03a2b","tag-orange":"#b35309","tag-amber":"#8f6200","tag-green":"#2e7d4f","tag-teal":"#0f7470","tag-blue":"#2f62b8","tag-purple":"#7a4cc0","tag-pink":"#b23a7a"},i2A={background:"#141513",foreground:"#ecece7",card:"#1b1c1a",primary:"#ecece7","primary-foreground":"#1b1c1a","primary-ink":"#ecece7",secondary:"#262724","secondary-foreground":"#ecece7",muted:"#1e1f1d","muted-foreground":"#a3a49c",accent:"#2a2b28","accent-foreground":"#ecece7",destructive:"#ec6a5e","destructive-foreground":"#141513",border:"#2d2e2b",input:"#4b4c47",ring:"#7d9ce6",success:"#5dbe80",warning:"#e2a83c",info:"#7ca5e8",highlight:"#4a4c1e","highlight-foreground":"#ecece7",overlay:"rgb(0 0 0 / 55%)","chart-1":"#ecece7","chart-2":"#8b8c85","chart-3":"#7ca5e8","chart-4":"#e2a83c","chart-5":"#5dbe80",sidebar:"#10110f","sidebar-foreground":"#c4c5bd","sidebar-primary":"#ecece7","sidebar-primary-foreground":"#141513","sidebar-accent":"#242522","sidebar-accent-foreground":"#ecece7","sidebar-border":"#262724","sidebar-ring":"#7d9ce6","tag-gray":"#9c9d95","tag-red":"#f2766b","tag-orange":"#f0954f","tag-amber":"#e3b341","tag-green":"#5dbe80","tag-teal":"#3fc1b4","tag-blue":"#79a3ee","tag-purple":"#b48ff0","tag-pink":"#ee82b8"},vU=["#000000","#ffffff"],UAQ=["destructive","success","warning","info"],YAQ=["tag-gray","tag-red","tag-orange","tag-amber","tag-green","tag-teal","tag-blue","tag-purple","tag-pink"];p2A=[["foreground","background",7],["foreground","card",7],["foreground","muted",7],["muted-foreground","background",4.5],["muted-foreground","card",4.5],["muted-foreground","muted",4.5],["muted-foreground","accent",4.5],["primary-ink","background",4.5],["primary-ink","card",4.5],["primary-foreground","primary",4.5],["secondary-foreground","secondary",4.5],["accent-foreground","accent",4.5],["destructive","background",4.5],["destructive","card",4.5],["destructive-foreground","destructive",4.5],["success","background",4.5],["success","card",4.5],["warning","background",4.5],["warning","card",4.5],["info","background",4.5],["info","card",4.5],["highlight-foreground","highlight",4.5],["sidebar-foreground","sidebar",4.5],["sidebar-foreground","sidebar-accent",4.5],["sidebar-accent-foreground","sidebar-accent",4.5],["sidebar-primary-foreground","sidebar-primary",4.5],["ring","background",4.5],["ring","card",4.5],["sidebar-ring","sidebar",3],["chart-1","background",3],["chart-1","card",3],...["gray","red","orange","amber","green","teal","blue","purple","pink"].flatMap((A)=>[[`tag-${A}`,"background",4.5],[`tag-${A}`,"muted",4.5]])];XAQ=["background","foreground","card","primary","primary-foreground","secondary","secondary-foreground","muted","muted-foreground","accent","accent-foreground","destructive","border","input","ring","chart-1","chart-2","chart-3","chart-4","chart-5","sidebar","sidebar-foreground","sidebar-primary","sidebar-primary-foreground","sidebar-accent","sidebar-accent-foreground","sidebar-border","sidebar-ring"];XM={id:"light",name:"Light",description:"Oatmilk's bright, quiet default.",scheme:"light",special:!1,palette:["#ffffff","#f4f3f1","#262923","#edf26a"],tokens:d2A},uH={id:"dark",name:"Dark",description:"Easy on the eyes after hours.",scheme:"dark",special:!1,palette:["#141513","#1b1c1a","#ecece7","#7d9ce6"],tokens:i2A},NAQ=[xU({id:"marathon",name:"Marathon",description:"Acid volt on black, with signal red and arc blue.",scheme:"dark",palette:["#c0fc04","#000000","#b10702","#0a65fe","#819074"],background:"#000000",foreground:"#fefef7",primary:"#c0fc04",primaryForeground:"#000000",card:XQ("#000000","#819074",0.08),muted:XQ("#000000","#819074",0.1),secondary:XQ("#000000","#819074",0.16),accent:XQ("#000000","#819074",0.2),mutedForeground:"#819074",border:XQ("#000000","#819074",0.24),input:XQ("#000000","#819074",0.5),sidebar:"#000000",sidebarAccent:XQ("#000000","#c0fc04",0.16),destructive:"#b10702",info:"#0a65fe",tokens:{"chart-2":"#819074","tag-red":wU("#b10702",["#000000","#0d0e0c"],"#fefef7"),"tag-blue":wU("#0a65fe",["#000000","#0d0e0c"],"#fefef7")}}),xU({id:"limelight",name:"Limelight",description:"Warm paper and charcoal, lit with electric lime.",scheme:"light",palette:["#9c9b9a","#f6f5f2","#353535","#e4f222"],background:"#f6f5f2",foreground:"#353535",primary:"#353535",primaryForeground:"#f6f5f2",card:"#ffffff",mutedForeground:"#9c9b9a",border:XQ("#f6f5f2","#9c9b9a",0.3),input:"#9c9b9a",ring:"#e4f222",highlight:"#e4f222",sidebarAccent:"#e4f222",tokens:{"chart-2":"#9c9b9a"}}),xU({id:"meadow",name:"Meadow",description:"Sunlit yellow and soft sage on cream.",scheme:"light",palette:["#e9dd4e","#dbdd59","#a5bb88","#9ab991"],background:XQ("#e9dd4e","#ffffff",0.9),foreground:XQ("#9ab991","#000000",0.8),primary:XQ("#a5bb88","#000000",0.6),secondary:XQ("#dbdd59","#ffffff",0.7),accent:XQ("#a5bb88","#ffffff",0.7),border:XQ("#a5bb88","#ffffff",0.65),input:"#9ab991",ring:"#9ab991",highlight:"#e9dd4e",sidebar:XQ("#dbdd59","#ffffff",0.82),sidebarAccent:"#a5bb88",tokens:{"chart-2":"#9ab991"}}),xU({id:"dusk",name:"Dusk",description:"Desert browns and lamp-lit taupe after sundown.",scheme:"dark",palette:["#786453","#7e674f","#181415","#575755"],background:"#181415",foreground:XQ("#786453","#ffffff",0.88),primary:XQ("#7e674f","#ffffff",0.4),primaryForeground:"#181415",card:XQ("#181415","#786453",0.08),muted:XQ("#181415","#786453",0.1),secondary:"#575755",accent:XQ("#181415","#786453",0.25),border:XQ("#181415","#786453",0.3),input:"#575755",highlight:"#786453",sidebar:XQ("#181415","#000000",0.3),sidebarAccent:XQ("#181415","#7e674f",0.3),tokens:{"chart-2":"#7e674f"}}),xU({id:"nocturne",name:"Nocturne",description:"Midnight glass and deep teal, like a city at 3 a.m.",scheme:"dark",palette:["#020a10","#050a0c","#010204","#192423"],background:"#050a0c",foreground:XQ("#192423","#ffffff",0.88),primary:XQ("#192423","#ffffff",0.62),primaryForeground:"#010204",card:XQ("#050a0c","#192423",0.45),muted:XQ("#050a0c","#192423",0.5),secondary:"#192423",accent:"#192423",border:"#192423",input:XQ("#192423","#ffffff",0.2),sidebar:"#020a10",sidebarAccent:"#192423",tokens:{"chart-2":XQ("#192423","#ffffff",0.3)}}),kU({id:"matcha",name:"Matcha",description:"Bright lime on clean white, with soft olive grays.",scheme:"light",css:`
306
306
  --background: oklch(1 0 0);
307
307
  --foreground: oklch(0.153 0.006 107.1);
308
308
  --card: oklch(1 0 0);
@@ -511,7 +511,7 @@ Error message: ${J$(B)}`,cause:B});this[W5A]=!0,this.value=Q,this.context=E}stat
511
511
  `&&!B.return)return J(j4(A,`
512
512
  `,E));if(B.return){if(I.slice(0,D).endsWith("\\"))return J({value:`${I.slice(0,D-1)}
513
513
  ${I.slice(D)}`,cursor:D});return{type:"submit"}}if(B.upArrow||B.downArrow){let G=_AQ(I,D,B.upArrow?-1:1);return G===null?{type:"history",direction:B.upArrow?-1:1}:J({value:I,cursor:G})}if(B.leftArrow)return J({value:I,cursor:B.ctrl||B.meta?qM(I,D):$XA(I,D)});if(B.rightArrow)return J({value:I,cursor:B.ctrl||B.meta?YXA(I,D):UXA(I,D)});if(B.home||B.ctrl&&Q==="a")return J({value:I,cursor:FM(I,D)});if(B.end||B.ctrl&&Q==="e")return J({value:I,cursor:jh(I,D)});if(B.meta&&Q==="b")return J({value:I,cursor:qM(I,D)});if(B.meta&&Q==="f")return J({value:I,cursor:YXA(I,D)});if(B.backspace){if(D===0)return{type:"ignore"};let G=B.meta||B.ctrl?qM(I,D):$XA(I,D);return J({value:I.slice(0,G)+I.slice(D),cursor:G})}if(B.delete){if(D>=I.length)return{type:"ignore"};return J({value:I.slice(0,D)+I.slice(UXA(I,D)),cursor:D})}if(B.ctrl&&Q==="w"){let G=qM(I,D);return J({value:I.slice(0,G)+I.slice(D),cursor:G})}if(B.ctrl&&Q==="u"){let G=FM(I,D);return J({value:I.slice(0,G)+I.slice(D),cursor:G})}if(B.ctrl||B.meta||B.escape||B.tab||B.pageUp||B.pageDown)return{type:"ignore"};if(!Q)return{type:"ignore"};return J(j4(A,Q,E))}class Rh{entries;limit;position;draft="";constructor(A=[],Q=200){this.entries=A;this.limit=Q;this.position=A.length}get all(){return this.entries}add(A){let Q=A.trim();if(!Q)return;this.entries=[...this.entries.filter((B)=>B!==Q),Q].slice(-this.limit),this.position=this.entries.length,this.draft=""}move(A,Q){if(this.position===this.entries.length)this.draft=Q;let B=this.position+A;if(B<0||B>this.entries.length)return null;return this.position=B,B===this.entries.length?this.draft:this.entries[B]}reset(){this.position=this.entries.length}}var KXA;var RD=W(()=>{KXA=new Intl.Segmenter(void 0,{granularity:"grapheme"})});function gh(A,Q,B={}){let E=B.prefix??[],I=E.reduce((z,F)=>z+Fh(F.text),0),D=Math.max(4,Q-I),J=B.mask?"•".repeat([...A.value].length):A.value,G=B.mask?[...A.value.slice(0,A.cursor)].length:A.cursor;if(!A.value&&B.placeholder){let z=B.focused?[{text:" ",inverse:!0}]:[];return[[...E,...z,{text:cH(B.placeholder,D-1)[0],color:L.faint}]]}let U=[],Y=0;for(let z of J.split(`
514
- `)){let F=z,V=Y;if(!F)U.push({text:"",start:V});while(F.length){let O=cH(F,D-1)[0]||[...F][0];U.push({text:O,start:V}),V+=O.length,F=F.slice(O.length)}Y+=z.length+1}let H=U.length-1;for(let z=0;z<U.length;z+=1){let F=U[z].start+U[z].text.length;if(G>=U[z].start&&G<=F){H=z;break}}let X=B.maxRows??U.length,N=Math.max(0,Math.min(H-X+1,U.length-X));return U.slice(N,N+X).map((z,F)=>{let V=F===0&&N===0?E:E.map((x)=>({...x,text:" ".repeat(Fh(x.text))}));if(!B.focused||N+F!==H)return[...V,{text:z.text}];let O=G-z.start,j=z.text.slice(0,O),b=[...z.text.slice(O)][0]??" ";return[...V,{text:j},{text:b,inverse:!0},{text:z.text.slice(O+(b===" "&&O>=z.text.length?0:b.length))}]})}function p0({state:A,width:Q,placeholder:B,focused:E=!0,maxRows:I,prefix:D,mask:J}){let G=gh(A,Q,{placeholder:B,focused:E,maxRows:I,prefix:D,mask:J});return R(e,{flexDirection:"column",children:G.map((U,Y)=>R(O4,{line:U},Y))})}var gD=W(async()=>{bB();HQ();await $0([dB(),g8()])});import{mkdirSync as OAQ,readFileSync as LAQ,writeFileSync as WAQ}from"node:fs";import{join as HXA}from"node:path";function NXA(A=qI()){try{let Q=JSON.parse(LAQ(HXA(A,XXA),"utf8"));return Array.isArray(Q)?Q.filter((B)=>typeof B==="string").slice(-ZXA):[]}catch{return[]}}function zXA(A,Q=qI()){try{OAQ(Q,{recursive:!0,mode:448}),WAQ(HXA(Q,XXA),JSON.stringify(A.slice(-ZXA)),{mode:384})}catch{return}}var XXA="history.json",ZXA=200;var qXA=W(()=>{AJ()});function jAQ(A){if(!/^\/\S*$/.test(A))return[];let Q=A.slice(1).toLowerCase();return FXA.filter((B)=>B.name.startsWith(Q)).concat(FXA.filter((B)=>!B.name.startsWith(Q)&&B.name.includes(Q)))}function MXA({onHeight:A,onSlash:Q}){let B=FB(),E=HG(B.chat),[I,D]=TD.useState({value:"",cursor:0}),[J,G]=TD.useState(0),U=TD.useRef(null);U.current??=new Rh(NXA());let Y=B.focus==="composer",H=B.layout.columns-4,X=Y?jAQ(I.value):[],N=E.pending,z=TD.useMemo(()=>{if(!N)return null;for(let t of E.snapshot.data.messages)for(let i of t.parts)if(i.type==="dynamic-tool"&&i.toolCallId===N.toolCallId)return i;return null},[N,E.snapshot]),F=N?N.request.kind==="tool-approval"?[{id:"approve",label:"Approve"},{id:"deny",label:"Don't allow"}]:YM(N.request):[],V=!!N&&!I.value,O=(t)=>{let i=t.trim();if(!i)return;if(U.current?.add(i),zXA(U.current?.all??[]),D({value:"",cursor:0}),i.startsWith("/")){let[UA,...CA]=i.slice(1).split(/\s+/);Q(UA.toLowerCase(),CA.join(" "));return}B.ask(i)};iQ((t,i)=>{if(i.escape){if(X.length&&I.value.startsWith("/")){D({value:"",cursor:0});return}if(E.busy){B.chat.cancel(),B.toast("Stopping…","info");return}B.setFocus("main");return}if(i.tab&&X.length){let CA=X[Math.min(J,X.length-1)];D({value:`/${CA.name} `,cursor:CA.name.length+2});return}if(i.tab){B.setFocus(i.shift?"main":B.layout.sidebarWidth?"sidebar":"main");return}if(X.length&&(i.upArrow||i.downArrow)){G((CA)=>(CA+(i.upArrow?-1:1)+X.length)%X.length);return}if(X.length&&i.return&&!i.meta&&!i.shift){let CA=X[Math.min(J,X.length-1)],GA=I.value.slice(1).split(/\s+/)[0];O(GA===CA.name?I.value:`/${CA.name}`);return}if(V&&F.length){if(i.upArrow||i.downArrow){B.chat.moveOption(i.upArrow?-1:1,F.length);return}let CA=/^[1-9]$/.test(t)?Number(t)-1:-1,GA=i.return?F[E.option]:CA>=0?F[CA]:N?.request.kind==="tool-approval"&&/^[yn]$/i.test(t)?F[t.toLowerCase()==="y"?0:1]:void 0;if(GA&&N){B.chat.respond([{requestId:N.request.requestId,optionId:GA.id}]).catch((iA)=>B.toast(String(iA?.message??iA),"danger"));return}}if(i.pageUp||i.pageDown)return;let UA=BI(I,t,i,U$);if(UA.type==="submit")O(I.value);else if(UA.type==="edit")D(UA.state),G(0);else if(UA.type==="history"){let CA=U.current?.move(UA.direction,I.value);if(CA!==null&&CA!==void 0)D({value:CA,cursor:CA.length})}},{isActive:Y}),z8((t)=>D((i)=>j4(i,t,U$)),{isActive:Y});let j=E.resuming?"Picking up where you left off…":N?.request.kind==="tool-approval"?"y to approve · n to decline · or type a message":N?"Choose with ↑↓ and ⏎, or type your own answer…":!B.aiEnabled?"Ask AI is off (--no-ai). Type / for commands":B.focusRecord?`Ask about ${B.focusRecord.label}…`:"Ask Oatmilk anything, or type / for commands",b=[{text:`${hA.prompt} `,color:Y?L.accent:L.faint,bold:!0}],x=gh(I,H,{placeholder:j,focused:Y,maxRows:RAQ,prefix:b}),v=N?.request.kind==="tool-approval"&&z?O8(z,N.request.prompt):null,w=X.slice(0,6),k=(B.focusRecord&&Y?1:0)+(w.length?w.length:0)+(V&&F.length?1+F.length:0),h=x.length+2+k;return TD.useEffect(()=>{A(h)},[h,A]),d(e,{flexDirection:"column",width:B.layout.columns,borderStyle:"single",borderColor:Y?L.focus:L.border,paddingX:1,children:[w.map((t,i)=>d(f,{color:i===Math.min(J,w.length-1)?L.focus:L.muted,children:[i===Math.min(J,w.length-1)?hA.pointer:" "," /",t.name.padEnd(9),R(f,{color:L.faint,children:t.description})]},t.name)),V&&F.length?d(PB,{children:[d(f,{color:L.warning,bold:!0,wrap:"truncate-end",children:[hA.ai," ",v??N?.request.prompt]}),F.map((t,i)=>d(f,{color:i===E.option?L.focus:L.text,wrap:"truncate-end",children:[i===E.option?hA.pointer:" "," ",i+1,". ",t.label,"description"in t&&t.description?d(f,{color:L.faint,children:[" ",t.description]}):null]},t.id))]}):null,B.focusRecord&&Y?d(f,{color:L.faint,wrap:"truncate-end",children:["About: ",R(f,{color:L.muted,children:B.focusRecord.label})]}):null,x.map((t,i)=>R(O4,{line:t},i))]})}var TD,FXA,RAQ=6;var VXA=W(async()=>{l1();L8();K$();RD();BE();pH();qXA();bB();HQ();await $0([dB(),gD(),g8()]);TD=pA(JQ(),1),FXA=[{name:"help",description:"Keys and commands"},{name:"new",description:"Start a new chat"},{name:"chats",description:"Reopen a recent chat"},{name:"model",description:"Where Ask AI thinks: Oatmilk, or Ollama or LM Studio here"},{name:"go",description:"Jump to a page or record (⌃K)"},{name:"search",description:"Search transactions, email, invoices and more"},{name:"run",description:"Run any Oatmilk action"},{name:"org",description:"Switch workspace (personal or a company)"},{name:"theme",description:"Change the theme (/theme dark)"},{name:"update",description:"Update oatmilk to the newest version (⌃U)"},{name:"browser",description:"Open this page in the browser"},{name:"logout",description:"Sign out of this machine"},{name:"quit",description:"Leave Oatmilk"}]});function OXA(A){let[Q,B]=p1.useState(null),E=p1.useRef(A);p1.useEffect(()=>{E.current=A},[A]);let I=p1.useCallback((G)=>{B(G),E.current(!0)},[]),D=p1.useCallback(()=>{B(null),E.current(!1)},[]);return{dialogs:p1.useMemo(()=>({prompt:(G)=>new Promise((U)=>I({kind:"prompt",title:G.title,label:G.label,minLength:G.minLength??0,placeholder:G.placeholder,mask:G.mask,state:{value:G.initial??"",cursor:(G.initial??"").length},resolve:U})),choose:(G)=>new Promise((U)=>I({kind:"choose",title:G.title,items:G.items,filter:{value:"",cursor:0},index:0,resolve:U})),confirm:(G)=>new Promise((U)=>I({kind:"confirm",title:G.title,body:G.body,danger:G.danger??!1,confirmLabel:G.confirmLabel??"Continue",resolve:U})),showSecret:(G,U,Y)=>new Promise((H)=>I({kind:"secret",title:G,secret:U,note:Y,resolve:H}))}),[I]),pending:Q,close:D,update:B}}function _XA(A,Q){let B=Q.toLowerCase().split(/\s+/).filter(Boolean);return A.map((E,I)=>({item:E,index:I})).filter(({item:E})=>B.every((I)=>E.label.toLowerCase().includes(I)||E.detail?.toLowerCase().includes(I))).map(({index:E})=>E)}function LXA({pending:A,close:Q,update:B,width:E,height:I}){let D=Math.min(72,E-4),J=(H)=>{Q(),H()};iQ((H,X)=>{if(A.kind==="prompt"){if(X.escape){J(()=>A.resolve(null));return}let N=BI(A.state,H,X,2000);if(N.type==="submit"){let z=A.state.value.trim();if(z.length<A.minLength){B({...A,error:A.minLength>1?`Write at least ${A.minLength} characters.`:"This can't be empty."});return}J(()=>A.resolve(z))}else if(N.type==="edit")B({...A,state:N.state,error:void 0});return}if(A.kind==="choose"){let N=_XA(A.items,A.filter.value);if(X.escape){J(()=>A.resolve(null));return}if(X.upArrow){B({...A,index:Math.max(0,A.index-1)});return}if(X.downArrow){B({...A,index:Math.min(N.length-1,A.index+1)});return}if(X.return){let F=N[A.index];if(F!==void 0)J(()=>A.resolve(A.items[F].value));return}let z=BI(A.filter,H,X,200);if(z.type==="edit")B({...A,filter:z.state,index:0});return}if(A.kind==="confirm"){if(X.escape||H==="n")J(()=>A.resolve(!1));else if(X.return||H==="y")J(()=>A.resolve(!0));return}if(X.return||X.escape)J(()=>A.resolve())}),z8((H)=>{if(A.kind==="prompt")B({...A,state:j4(A.state,H,2000),error:void 0});if(A.kind==="choose")B({...A,filter:j4(A.filter,H,200),index:0})});let G,U="";if(A.kind==="prompt")U="⏎ save · Esc cancel",G=d(PB,{children:[R(f,{color:L.muted,wrap:"wrap",children:A.label}),R(e,{borderStyle:"single",borderColor:L.focus,paddingX:1,marginTop:1,children:R(p0,{state:A.state,width:D-8,placeholder:A.placeholder,maxRows:4,mask:A.mask})}),A.error?R(f,{color:L.danger,children:A.error}):null]});else if(A.kind==="choose"){let H=_XA(A.items,A.filter.value),X=Math.max(3,Math.min(12,I-10)),N=Math.max(0,Math.min(A.index-Math.floor(X/2),H.length-X));U="Type to filter · ↑↓ choose · ⏎ pick · Esc cancel",G=d(PB,{children:[R(e,{borderStyle:"single",borderColor:L.border,paddingX:1,children:R(p0,{state:A.filter,width:D-8,placeholder:"Filter…"})}),H.slice(N,N+X).map((z,F)=>{let V=A.items[z],O=N+F===A.index;return d(e,{justifyContent:"space-between",children:[d(f,{color:O?L.focus:L.text,wrap:"truncate-end",children:[O?hA.pointer:" "," ",V.label]}),V.detail?d(f,{color:L.faint,wrap:"truncate-end",children:[" ",V.detail]}):null]},z)}),!H.length?R(f,{color:L.muted,children:"Nothing matches."}):null]})}else if(A.kind==="confirm")U=`y / ⏎ ${A.confirmLabel.toLowerCase()} · n / Esc cancel`,G=A.body?R(f,{color:L.muted,wrap:"wrap",children:A.body}):null;else U="⏎ done",G=d(PB,{children:[R(e,{borderStyle:"single",borderColor:L.highlight,paddingX:1,marginY:1,children:R(f,{color:L.highlight,wrap:"wrap",children:A.secret})}),R(f,{color:L.muted,wrap:"wrap",children:A.note})]});let Y=A.kind==="confirm"&&A.danger;return R(e,{position:"absolute",top:0,left:0,width:E,height:I,alignItems:"center",justifyContent:"center",children:d(e,{flexDirection:"column",width:D,borderStyle:"single",borderColor:Y?L.danger:L.focus,paddingX:2,paddingY:1,backgroundColor:L.panel,children:[R(f,{bold:!0,color:Y?L.danger:L.text,wrap:"wrap",children:A.title}),R(e,{flexDirection:"column",marginTop:1,children:G}),R(e,{marginTop:1,children:R(f,{color:L.faint,children:U})})]})})}var p1;var WXA=W(async()=>{RD();bB();HQ();await $0([dB(),gD()]);p1=pA(JQ(),1)});var jXA=()=>{};var RXA=()=>{};var gXA=()=>{};function TAQ(A){try{return new Intl.NumberFormat("en",{style:"currency",currency:A}).resolvedOptions().maximumFractionDigits??2}catch{return 2}}function aQ(A,Q="CAD"){if(A===void 0||A===null||!/^-?\d+$/.test(A))return"—";let B=TAQ(Q),E=BigInt(A),I=E<0n?-E:E,D=10n**BigInt(B),J=(I/D).toLocaleString("en-CA"),G=B?`.${(I%D).toString().padStart(B,"0")}`:"";return`${E<0n?"−":""}${Q} ${J}${G}`}function oQ(A){if(!A)return"—";let Q=new Date(A.length===10?`${A}T12:00:00Z`:A);return Number.isNaN(Q.valueOf())?"—":new Intl.DateTimeFormat("en-CA",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"}).format(Q)}var iH=W(()=>{jXA();Yh();RXA();gXA();yH();yH()});function Th(A){return typeof A==="string"&&PAQ.includes(A)}function W0(A,Q,B=`${Q}s`){return A===1?Q:B}function TXA(A){return A==="match_payout"?"/finance/reconcile?view=stripe":`/finance/transactions?status=needs_you&ask=${encodeURIComponent(A)}`}var PAQ,MM;var Ph=W(()=>{PAQ=["forward_receipt","review_document","contractor_invoice","choose_contractor","choose_category","confirm_business","confirm_income","confirm_tax","match_payout","approve","import_statement","reimbursement_receipts"];MM={forward_receipt:{label:(A)=>`Find ${A} ${W0(A,"receipt")}`,phrase:(A)=>`${A} ${W0(A,"receipt")} to find`,detail:"Oatmilk searched the inbox and the bank and couldn't find them.",action:"Find receipts"},review_document:{label:(A)=>`Review documents for ${A} ${W0(A,"transaction")}`,phrase:(A)=>`${A} ${W0(A,"transaction")} with documents to review`,detail:"The originals are attached. Their details, business use and tax still need review.",action:"Review documents"},reimbursement_receipts:{label:(A)=>`Add receipts for ${A} ${W0(A,"reimbursement")}`,phrase:(A)=>`${A} ${W0(A,"reimbursement")} needing receipts`,detail:"Add the original purchases and their receipts to support the reimbursement payment.",action:"Add reimbursement receipts"},contractor_invoice:{label:(A)=>`Add ${A} contractor ${W0(A,"invoice")}`,phrase:(A)=>`${A} contractor ${W0(A,"invoice")} to add`,detail:"Contractor payments need the contractor's invoice or your agreement, not a receipt.",action:"Add invoices"},choose_contractor:{label:(A)=>`Identify ${A} contractor ${W0(A,"payment")}`,phrase:(A)=>`${A} contractor ${W0(A,"payment")} to identify`,detail:"Choose who was paid, or mark a payment as unrelated to contractors.",action:"Identify contractors"},choose_category:{label:(A)=>`Choose a category for ${A} ${W0(A,"transaction")}`,phrase:(A)=>`${A} ${W0(A,"category","categories")} to choose`,detail:"Your answer is remembered for the same merchant.",action:"Choose categories"},confirm_business:{label:(A)=>`Check ${A} possible personal ${W0(A,"purchase")}`,phrase:(A)=>`${A} possible personal ${W0(A,"purchase")} to check`,detail:"Confirm whether they were for the business.",action:"Check purchases"},confirm_income:{label:(A)=>`Confirm ${A} incoming ${W0(A,"payment")}`,phrase:(A)=>`${A} incoming ${W0(A,"payment")} to confirm`,detail:"Link the invoice or confirm the income and its tax.",action:"Confirm income"},confirm_tax:{label:(A)=>`Confirm sales tax on ${A} Stripe ${W0(A,"payment")}`,phrase:(A)=>`sales tax on ${A} Stripe ${W0(A,"payment")} to confirm`,detail:"Stripe didn't record the tax for them.",action:"Confirm sales tax"},match_payout:{label:(A)=>`Match ${A} Stripe ${W0(A,"payout")} to deposits`,phrase:(A)=>`${A} Stripe ${W0(A,"payout")} to match`,detail:"Connect or import the account that received them.",action:"Match payouts"},approve:{label:(A)=>`Approve ${A} prepared ${W0(A,"transaction")}`,phrase:(A)=>`${A} prepared ${W0(A,"transaction")} to approve`,detail:"Everything is filled in and waiting for you.",action:"Review and approve"},import_statement:{label:(A)=>`Import card statements for ${A} ${W0(A,"receipt")}`,phrase:(A)=>`card statements to import for ${A} ${W0(A,"receipt")}`,detail:"Their receipts are waiting to be matched to the card's statement.",action:"Import statements"}}});function wAQ(A){return A==="directory"?"/people/contractors":`/people/contractors?view=${A}`}function N$(A,Q){return{label:A,view:Q,href:wAQ(Q)}}function PD(A,Q,B,E,I=!1){return{...N$(A,Q),group:B,description:E,...I?{adminOnly:I}:{}}}function bXA(A){if(!A)return"directory";if(bAQ.has(A))return A;return SAQ[A]??"directory"}var SAQ,PXA,SXA,wXA,vXA,vAQ,nH,bAQ;var kXA=W(()=>{SAQ={people:"directory"};PXA=N$("Contractors","directory"),SXA=N$("Settings","setup"),wXA=[N$("Timesheets","timesheets"),N$("Payouts","payouts"),N$("Tax forms","tax"),N$("Insights","insights")],vXA=[PXA,...wXA,SXA];vAQ=[PD("Reminders and approvals","settings","setup","Who approves hours, when reminders go out, and how payouts are sent.",!0),PD("Job roles","roles","setup","The roles, levels and pay bands you hire for."),PD("Agreement templates","templates","setup","The agreements you send contractors to sign."),PD("Hours form","hours-form","setup","Choose what contractors fill in when they log hours."),PD("Import contractors","import","setup","Add several contractors at once from a spreadsheet."),PD("Documents","documents","records","Invoices and files contractors have sent."),PD("Timesheet history","history","records","Every past timesheet, paid or not."),PD("Email activity","email","records","Which emails were sent to contractors."),PD("Activity log","activity","records","Everything that changed, and who changed it.")],nH=[{...PXA,label:"All contractors"},...wXA,SXA,...vAQ],bAQ=new Set(nH.map((A)=>A.view))});function kAQ(A,Q){if(Q?.you)return"You invited them";if(Q?.name)return`Invited by ${Q.name}`;return A==="team"?"Joined your team":"Joined by invitation"}function xAQ(A){return{id:`join-notice:${A.id}`,label:A.summary,detail:kAQ(A.kind,A.invitedBy),href:A.href,verb:"View"}}function xXA(A){return(A?.items??[]).map(xAQ)}var yXA=()=>{};function fXA(A){return A.items.map((Q)=>({id:`snooze-notice:${Q.itemId}`,label:Q.title,detail:"Your snooze ended. This item needs attention again.",href:`/checklist?item=${encodeURIComponent(Q.itemId)}`,verb:"Review"}))}function wh(A){return vh.find((Q)=>Q.id===A)}function bh(A){let Q=A.get("view");if(Q&&Sh[Q]&&Sh[Q]!=="all")return wh(Sh[Q]);return yAQ.get(A.get("status")??"")??wh("all")}function fAQ(A){let Q=wh(A);if(Q.id==="all")return"/finance/invoices";if(Q.kind==="invoices")return`/finance/invoices?status=${Q.archived?"archived":Q.status}`;return`/finance/invoices?view=${Q.id==="archived_accounts"?"archived-accounts":Q.id}`}function kh(){return{id:"invoices",title:"Invoices",groups:["main","work","closed","accounts"].map((Q)=>({...hXA[Q]?{label:hXA[Q]}:{},links:vh.filter((B)=>B.group===Q).map((B)=>({id:B.id,label:B.label,href:fAQ(B.id),...B.countKey?{countKey:B.countKey}:{}}))}))}}var vh,yAQ,Sh,hXA;var uXA=W(()=>{vh=[{id:"all",label:"All invoices",heading:"Invoices",kind:"invoices",group:"main"},{id:"needs_action",label:"Needs action",heading:"Needs action",kind:"invoices",status:"needs_action",group:"main",countKey:"invoicesNeedAction"},{id:"open",label:"Unpaid",heading:"Unpaid invoices",kind:"invoices",status:"open",group:"main"},{id:"overdue",label:"Overdue",heading:"Overdue invoices",kind:"invoices",status:"overdue",group:"main",countKey:"invoicesOverdue"},{id:"paid",label:"Paid",heading:"Paid invoices",kind:"invoices",status:"paid",group:"main"},{id:"draft",label:"Drafts",heading:"Drafts",kind:"invoices",status:"draft",group:"work",countKey:"invoicesDrafts"},{id:"scheduled",label:"Scheduled",heading:"Scheduled",kind:"scheduled",group:"work"},{id:"uncollectible",label:"Written off",heading:"Written off",kind:"invoices",status:"uncollectible",group:"closed"},{id:"void",label:"Cancelled",heading:"Cancelled invoices",kind:"invoices",status:"void",group:"closed"},{id:"archived",label:"Archived",heading:"Archived invoices",kind:"invoices",archived:"only",group:"closed"},{id:"customers",label:"Customers",heading:"Customers",kind:"accounts",accounts:"customers",group:"accounts"},{id:"vendors",label:"Vendors",heading:"Vendors",kind:"accounts",accounts:"vendors",group:"accounts"},{id:"archived_accounts",label:"Archived",heading:"Archived customers and vendors",kind:"accounts",accounts:"archived",group:"accounts"}],yAQ=new Map(vh.filter((A)=>A.status||A.archived).map((A)=>[A.archived?"archived":A.status,A])),Sh={scheduled:"scheduled",customers:"customers",vendors:"vendors",accounts:"customers","archived-accounts":"archived_accounts",invoices:"all"};hXA={main:void 0,work:void 0,closed:"Closed",accounts:"Customers and vendors"}});function xh(A,Q){let B=mXA.find((E)=>E===A)??"overview";return Q!=="admin"&&lXA.includes(B)?"overview":B}function pXA(A){return cXA[A]}function dXA(A,Q={}){let B=new URLSearchParams(A==="overview"?Q:{view:A,...Q}).toString();return B?`/developers?${B}`:"/developers"}function hAQ(A){return mXA.filter((Q)=>A==="admin"||!lXA.includes(Q))}function iXA(A){let Q=new Set(hAQ(A)),B=(I)=>({id:I,label:cXA[I],href:dXA(I)}),E=(I)=>I.filter((D)=>Q.has(D)).map(B);return{id:"developers",title:"Developers",groups:[{links:E(["overview","keys","webhooks"])},{label:"Monitor",links:E(["usage","requests"])},{label:"Build",links:E(["connect"])}]}}var mXA,cXA,lXA;var yh=W(()=>{mXA=["overview","keys","webhooks","usage","requests","connect"],cXA={overview:"Overview",keys:"API keys",webhooks:"Webhooks",usage:"Usage",requests:"Request log",connect:"AI apps"},lXA=["webhooks"]});function uh(A){return uAQ.find((Q)=>Q===A)??"overview"}function nXA(A){return hh[A]}function mAQ(A,Q={}){let B=new URLSearchParams(A==="overview"?{}:{view:A});for(let[I,D]of Object.entries(Q))B.set(I,D);let E=B.toString();return`/chief-of-staff${E?`?${E}`:""}`}function zG(A,Q=hh[A],B=A,E={}){return{id:B,label:Q,href:mAQ(A,E)}}function mh(A=[]){let Q=A.find((E)=>E.connected),B=A.filter((E)=>!E.connected);return{id:"chiefOfStaff",title:"Chief of Staff",groups:[{links:[zG("overview"),zG("activity")]},{label:"Channels",links:[zG("server",Q?.name??hh.server),...B.map((E)=>zG("server",E.name,`server-${E.guildId}`,{server:E.guildId}))]},{label:"Permissions",links:[zG("people"),zG("tools")]},{label:"Settings",links:[zG("schedules"),zG("settings")]}]}}function aXA(A){let Q=uh(A.get("view")),B=A.get("server");return Q==="server"&&B&&/^\d{17,20}$/.test(B)?`server-${B}`:Q}var fh="/chief-of-staff",uAQ,hh;var oXA=W(()=>{uAQ=["overview","server","people","tools","schedules","activity","settings"],hh={overview:"Overview",server:"Discord server",people:"People and roles",tools:"Tools and access",schedules:"Scheduled posts",activity:"Activity",settings:"General"}});var cAQ,z$="/god-mode",lAQ,pAQ,okQ;var ch=W(()=>{cAQ=["/inbox","/checklist","/calendar","/ai","/compliance","/chief-of-staff","/logs","/history","/developers","/settings"],lAQ=[...cAQ,"/finance","/legal","/people","/insights"],pAQ=["accounting","ops",...lAQ.map((A)=>A.slice(1))],okQ=new RegExp(`^(?:\\/onboarding(?:[?#][^\\s\\\\]*)?|\\/(?:${pAQ.join("|")})(?:[/?#][^\\s\\\\]*)?|\\/(?:[?#][^\\s\\\\]*)?)$`)});function uU(A){return Object.entries(hU).filter(([,E])=>A===E||A.startsWith(`${E}/`)).sort((E,I)=>I[1].length-E[1].length)[0]?.[0]??iAQ[A]??"home"}function VM(A){return nAQ[A]}function sAQ(A){let Q=bXA(A);if(Q==="directory")return;return nH.find((B)=>B.view===Q)?.label}function _M(A){if(A.documentWriter)return"Write an agreement";if(A.agreementComposer)return A.search.get("draft")?"Continue your agreement":"New agreement";return rAQ[A.view]?.(A)??VM(A.view)}function tAQ(A){return A==="admin"||A==="finance"}function sXA(A){if(A==="reconcile")return"transactions";if(A==="calendar")return"checklist";if(A==="tax")return"taxInfo";return A}function AQQ(A){return eAQ.find((Q)=>Q===A)??"overview"}function tXA(){return{id:"godMode",title:"God Mode",groups:[{links:[{id:"overview",label:"Overview",href:z$},{id:"signups",label:"Sign-ups",href:`${z$}?view=signups`},{id:"workspaces",label:"Workspaces",href:`${z$}?view=workspaces`},{id:"experiments",label:"Experiments",href:`${z$}?view=experiments`}]}]}}function AZA(A){return eXA.find((Q)=>Q===A)??"finance"}function QZA(){return{id:"insights",title:"Insights",groups:[{links:eXA.map((A)=>({id:A,label:A[0].toUpperCase()+A.slice(1),href:A==="finance"?"/insights":`/insights?view=${A}`}))}]}}function QQQ(A,Q="company"){let B=BZA.filter((I)=>Q!=="personal"||I.key!=="contractors"),E={id:"uploads",label:SD.uploads,href:"/inbox?view=uploads"};if(A==="contributor")return{id:"inbox",title:"Inbox",groups:[{links:[{id:"mine",label:SD.mine,href:"/inbox"},E,{id:"connected",label:SD.connected,href:"/inbox?view=connected"}]}]};return{id:"inbox",title:"Inbox",groups:[{links:[{id:"receipts",label:SD.receipts,href:"/inbox?view=receipts"},{id:"email",label:SD.email,href:"/inbox?view=email"},...A==="admin"?[{id:"quarantine",label:SD.quarantine,href:"/inbox?view=email&mailStatus=quarantined"}]:[],E]},{label:"Mailboxes",links:B.map((I)=>({id:`mailbox-${I.key}`,label:I.label,href:`/inbox?view=email&mailbox=${I.key}`}))},{label:"Connect",links:[{id:"connected",label:SD.connected,href:"/inbox?view=connected"}]},...A==="admin"||A==="finance"?[{label:"Settings",links:[{id:"ai",label:SD.ai,href:"/inbox?view=ai"}]}]:[]]}}function IZA(A,Q){let B=A.get("view");if(B==="connected")return"connected";if(B==="uploads")return"uploads";if(B==="ai"&&(Q==="admin"||Q==="finance"))return"ai";if(Q==="contributor")return"mine";if(B==="receipts")return"receipts";if(Q==="admin"&&A.get("mailStatus")==="quarantined")return"quarantine";let E=A.get("mailbox");return E&&/^[a-z][a-z0-9_-]{1,39}$/.test(E)?`mailbox-${E}`:"email"}function BQQ(A){return SD[A]??BZA.find((Q)=>`mailbox-${Q.key}`===A)?.label??"Inbox"}function DZA(A,Q,B=!1){let E=IQQ.find((I)=>I===A)??"overview";if(Q==="contributor")return"connections";return Q!=="admin"&&EQQ.includes(E)?"overview":E}function DQQ(A){return EZA[A]}function JZA(A){let Q=A==="admin",B=(I,D)=>({id:I,label:EZA[I],href:I==="overview"?"/ai":`/ai?view=${I}`,...D?{countKey:D}:{}}),E=[B("playground"),...Q?[B("classifiers"),B("memory"),B("settings")]:[]];return{id:"ai",title:"AI",groups:[{links:[B("overview","activeJobs"),B("agents"),B("connections")]},{label:"Advanced",links:E}]}}function JQQ(A){return A&&Object.hasOwn(lh,A)?A:null}function rXA(A="company"){let Q=Object.keys(lh).filter((B)=>B!=="slips"||A!=="personal").map((B)=>({id:B,label:lh[B],href:`/finance/tax?view=${B}`}));return{id:"tax",title:"Taxes",groups:[{links:[{id:"info",label:"Tax info",href:"/finance/tax/info"},{id:"prep",label:"Year-end",href:"/finance/tax"},{id:"stripe",label:"Stripe for the year",href:"/finance/tax?view=stripe"},{id:"records",label:"Records",href:"/finance/tax?view=records"}]},{label:"File it yourself",links:Q},{label:"Company",links:[{id:"shareholders",label:"Shareholders",href:"/finance/tax?view=shareholders"}]}]}}function CZA(A){return GZA.find((Q)=>Q===A)??"ask"}function CQQ(A){return A==="ask"?"":A==="library"?"Compliance library":A==="items"?"Open items":"Compliance research"}function ph(A,Q){if(A!=="admin"&&A!=="finance")return[];return GZA.filter((B)=>B==="ask"||B==="library"||B==="items"&&A==="admin"||B==="research"&&A==="admin"&&Q)}function $ZA(A,Q){let B=ph(A,Q),E=(D)=>({id:D,label:GQQ[D],href:D==="ask"?"/compliance":`/compliance?view=${D}`});return{id:"compliance",title:"Compliance",groups:[{links:B.filter((D)=>D!=="research").map(E)},...B.includes("research")?[{label:"Platform",links:[E("research")]}]:[]]}}function YZA(A,Q){let B=$QQ.find((E)=>E===A)??"postings";if(Q==="contributor"&&B==="board")return"postings";return B}function UQQ(A){return UZA[A]}function KZA(A){let Q=A!=="contributor",B=(E)=>({id:E,label:UZA[E],href:E==="postings"?"/people/recruiting":`/people/recruiting?view=${E}`});return{id:"people",title:"People",groups:[{label:"Recruiting",links:[B("postings"),B("interviews"),...Q?[B("board")]:[]]},...Q?[{label:"Team",links:[{id:"contractors",label:"Contractors",href:"/people/contractors"},{id:"roles",label:"Job roles",href:"/people/contractors?view=roles"},{id:"timesheets",label:"Timesheets",href:"/people/contractors?view=timesheets"}]}]:[]]}}function ZZA(A){return HZA.find((Q)=>Q===A)??(A?YQQ[A]:void 0)??"all"}function KQQ(A){return XZA[A]}function HQQ(A){return A==="all"?"/legal/agreements":`/legal/agreements?view=${A}`}function XQQ(A="company"){return HZA.filter((Q)=>A!=="personal"||Q!=="contracts"&&Q!=="jobs")}function NZA(A="company"){let Q=(B)=>({id:B,label:XZA[B],href:HQQ(B)});return{id:"documents",title:"Agreements",groups:[{links:XQQ(A).map(Q)}]}}function zZA(A,Q="company"){return Q!=="personal"||!ZQQ.has(A)}function qZA(A,Q){return Q&&(A==="admin"||A==="finance")}function E1(A,Q,B=!1,E="company"){if(!zZA(A,E))return null;if(A==="chiefOfStaff")return qZA(Q,B)?mh():null;if(A==="insights"&&Q!=="contributor")return QZA();if(A==="godMode")return Q==="admin"&&B?tXA():null;if(A==="people")return KZA(Q);if(A==="ai"&&Q!=="contributor")return JZA(Q);if(A==="developers")return iXA(Q);if(A==="compliance")return ph(Q,B).length?$ZA(Q,B):null;if(A==="inbox")return QQQ(Q,E);if(A==="taxInfo"&&Q!=="contributor")return rXA(E);if(A==="tax"&&Q!=="contributor")return rXA(E);if(A==="documents"&&Q!=="contributor")return NZA(E);if(A==="invoices"&&Q!=="contributor")return kh();if(A!=="transactions"&&A!=="reconcile")return null;let I=Q!=="contributor",D=Q==="admin"||Q==="finance";return{id:"transactions",title:"Transactions",groups:[{links:[{id:"all",label:"All transactions",href:"/finance/transactions"},{id:"needs_you",label:"Needs you",href:"/finance/transactions?status=needs_you",countKey:"needsYou"},{id:"working",label:"AI working",href:"/finance/transactions?status=working",countKey:"working"},{id:"done",label:"Done",href:"/finance/transactions?status=reviewed"}]},...I?[{links:[{id:"projects",label:"Projects",href:"/finance/transactions?view=projects"},...D?[{id:"merchants",label:"Merchants",href:"/finance/transactions?view=merchants"},{id:"trips",label:"Trips",href:"/finance/transactions?view=trips"}]:[]]},{label:"Reconcile",links:[{id:"matching",label:"Receipt matching",href:"/finance/reconcile?view=matching",countKey:"matching"},{id:"stripe",label:"Stripe payouts",href:"/finance/reconcile?view=stripe",countKey:"stripe"},{id:"bank",label:"Bank transactions",href:"/finance/reconcile?view=bank"}]},{label:"Accounts",links:[{id:"accounts",label:"Accounts and imports",href:"/finance/transactions?view=accounts"},...D?[{id:"statements",label:"Statements",href:"/finance/transactions?view=statements"}]:[]]}]:[]]}}function NQQ(A,Q,B="admin"){if(A==="chiefOfStaff")return aXA(Q);if(A==="insights")return AZA(Q.get("view"));if(A==="godMode")return AQQ(Q.get("view"));if(A==="ai")return DZA(Q.get("view"),B);if(A==="developers")return xh(Q.get("view"),B);if(A==="compliance")return CZA(Q.get("view"));if(A==="inbox")return IZA(Q,B);if(A==="taxInfo")return"info";if(A==="tax")return Q.get("view")==="records"?"records":Q.get("view")==="stripe"?"stripe":Q.get("view")==="shareholders"?"shareholders":JQQ(Q.get("view"))??"prep";if(A==="people")return YZA(Q.get("view"),B);if(A==="documents")return ZZA(Q.get("view"));if(A==="invoices")return bh(Q).id;if(A==="reconcile")return["stripe","bank"].includes(Q.get("view")??"")?Q.get("view"):"matching";if(Q.get("view")==="accounts")return"accounts";if(Q.get("view")==="projects")return"projects";if(Q.get("view")==="merchants")return"merchants";if(Q.get("view")==="trips")return"trips";if(Q.get("view")==="statements")return"statements";let E=Q.get("status");return E==="needs_you"?"needs_you":E==="working"?"working":E==="reviewed"?"done":"all"}function q$(A,Q=!1,B="company"){return zQQ(A,Q,B).filter((E)=>zZA(E.id,B))}function zQQ(A,Q,B){let E=A!=="contributor",I=(J,G)=>tAQ(A)?[{id:J,area:G,label:"AI",href:hU[J],children:[]}]:[],D=(J,G)=>J.groups.flatMap((U)=>U.links).filter((U)=>U.id!==G).map((U)=>({label:U.label,href:U.href,view:U.id}));return[{id:"home",area:"ops",label:"Home",href:"/",children:[]},{id:"inbox",area:"ops",label:"Inbox",href:"/inbox",children:[...E?[{label:"Email",href:"/inbox?view=email",view:"email"},{label:"Receipts",href:"/inbox?view=receipts",view:"receipts"}]:[{label:"My receipts",href:"/inbox",view:"receipts"}],{label:"Connected inboxes",href:"/inbox?view=connected",view:"connected"}]},...E?[{id:"checklist",area:"ops",label:"Checklist",href:"/checklist",children:[{label:"Calendar",href:"/calendar",view:"calendar"}]},{id:"ai",area:"ops",label:"Autopilot",href:"/ai",children:D(JZA(A),"overview")},...ph(A,Q).length?[{id:"compliance",area:"ops",label:"Compliance",href:"/compliance",children:D($ZA(A,Q),"ask")}]:[],...qZA(A,Q)?[{id:"chiefOfStaff",area:"ops",label:"Chief of Staff",href:fh,children:D(mh(),"overview")}]:[]]:[],...A==="admin"?[{id:"logs",area:"ops",label:"Logs",href:"/logs",children:[]}]:[],...A==="accountant"?[]:[{id:"developers",area:"ops",label:"Developers",href:"/developers",children:[]}],...A==="admin"&&Q?[{id:"godMode",area:"ops",label:"God Mode",href:z$,children:D(tXA(),"overview")}]:[],...I("financeAi","finance"),{id:"transactions",area:"finance",label:"Transactions",href:"/finance/transactions",children:[{label:"Needs you",href:"/finance/transactions?status=needs_you",view:"needs_you"},...E?[{label:"Projects",href:"/finance/transactions?view=projects",view:"projects"},...A==="admin"||A==="finance"?[{label:"Merchants",href:"/finance/transactions?view=merchants",view:"merchants"},{label:"Trips",href:"/finance/transactions?view=trips",view:"trips"}]:[],{label:"Receipt matching",href:"/finance/reconcile?view=matching",view:"matching"},{label:"Stripe payouts",href:"/finance/reconcile?view=stripe",view:"stripe"},{label:"Bank transactions",href:"/finance/reconcile?view=bank",view:"bank"},{label:"Accounts and imports",href:"/finance/transactions?view=accounts",view:"accounts"},...A==="admin"||A==="finance"?[{label:"Statements",href:"/finance/transactions?view=statements",view:"statements"}]:[]]:[]]},...A==="accountant"?[]:[{id:"reimbursements",area:"finance",label:"Reimbursements",href:hU.reimbursements,children:[]}],...E?[{id:"invoices",area:"finance",label:"Invoices",href:"/finance/invoices",children:D(kh(),"all")},{id:"financialStatements",area:"finance",label:"Financial statements",href:hU.financialStatements,children:[]},{id:"taxInfo",area:"finance",label:"Taxes",href:"/finance/tax/info",children:[]},...A==="admin"||A==="finance"?[{id:"budgets",area:"finance",label:"Budgets",href:hU.budgets,children:[{label:"Spending",href:"/finance/budgets?part=spending",view:"spending"},{label:"Reserves",href:"/finance/budgets?part=reserves",view:"reserves"}]}]:[],{id:"reports",area:"finance",label:"Reports",href:"/finance/reports",children:[]},...A==="admin"||A==="finance"?[{id:"subscriptions",area:"finance",label:"Subscriptions",href:hU.subscriptions,children:[]}]:[],...I("insightsAi","insights"),{id:"insights",area:"insights",label:"Insights",href:"/insights",children:D(QZA(),"finance")},...I("legalAi","legal"),{id:"documents",area:"legal",label:"Agreements",href:"/legal/agreements",children:D(NZA(B))},...I("peopleAi","people"),{id:"people",area:"people",label:"Recruiting",href:"/people/recruiting",children:D(KZA(A))},{id:"contractors",area:"people",label:"Contractors",href:"/people/contractors",children:vXA}]:[{id:"people",area:"people",label:"Interviews",href:"/people/recruiting?view=interviews",children:[]}],...A==="admin"||A==="finance"?[{id:"history",area:"ops",label:"History",href:"/history",children:[]}]:[],{id:"settings",area:"ops",label:"Settings",href:"/settings",children:[]}]}function MZA(A,Q=!1,B="company"){let E=q$(A,Q,B).filter((I)=>I.id!=="settings"&&I.id!=="history");return dAQ.map((I)=>({...I,destinations:E.filter((D)=>D.area===I.id)})).filter((I)=>I.destinations.length>0)}function qQQ(A,Q,B){let E=A==="choose_category"&&B&&B<Q?`From ${B} ${B===1?"merchant":"merchants"}. One answer settles each merchant's other transactions.`:MM[A].detail;return{id:`ask-${A}`,label:MM[A].label(Q),detail:E,href:TXA(A),verb:MM[A].action}}function FQQ(A,Q){let B=Q.length===1?`card ending ${Q[0]}`:Q.length?`cards ending ${Q.slice(0,-1).join(", ")} and ${Q.at(-1)}`:"card";return{id:"card-receipts",label:`Find ${A} ${A===1?"receipt":"receipts"} for your ${Q.length>1?"cards":"card"}`,detail:`Purchases on your ${B}`,href:"/",verb:"Add receipts"}}function VQQ(A){return{id:"accountant-questions",label:`Your accountant asked ${A} ${A===1?"question":"questions"}`,detail:"Answer them so they can finish your books.",href:"/settings?section=people&questions=open",verb:"Answer"}}function _QQ(A){return{id:"accountant-changes",label:`Your accountant asked for ${A} ${A===1?"change":"changes"}`,detail:"Approve or decline each one. Nothing changes until you approve.",href:"/settings?section=people",verb:"Review"}}function OQQ(A,Q){let B=[...A!=="accountant"?[{label:"Your requests",reads:[MQQ],items:([E])=>{let I=E.total??0;return I>0?[{id:"personal-requests",label:`${I} ${I===1?"request needs":"requests need"} you`,detail:"People on your team are waiting for your help.",href:"/?requests=mine",verb:"Review"}]:[]}}]:[],{label:"Receipt processing",reads:[{action:"inbox.list",input:{status:"failed",limit:5}}],items:([E])=>{let I=E;return I.items.length?[{id:"receipt-failures",label:"Review failed receipts",detail:`${I.items.length}${I.nextCursor?"+":""} failed submissions`,href:"/inbox?view=receipts",verb:"Review"}]:[]}},{label:"Receipt review",reads:[{action:"inbox.list",input:{status:"review",limit:5}}],items:([E])=>{let I=E;return I.items.length?[{id:"receipt-review",label:A==="contributor"?"Check your receipts":"Review receipts",detail:`${I.items.length}${I.nextCursor?"+":""} submissions`,href:"/inbox?view=receipts",verb:"Review"}]:[]}},{label:"Your cards",reads:[{action:"attention.mine",input:{limit:5}}],items:([E])=>{let I=E;return I.total?[FQQ(I.total,I.cards)]:[]}}];if(A==="contributor")return B;if(B.unshift({label:"Autopilot",reads:[{action:"attention.list",input:{limit:1}}],items:([E])=>{let I=E,D=I.groups.filter((J)=>J.count>0&&Th(J.kind)).map((J)=>qQQ(J.kind,J.count,J.merchants));if(I.contractorQuestions?.total)D.push({id:"contractor-payment-questions",label:`Identify ${I.contractorQuestions.total} historical contractor ${I.contractorQuestions.total===1?"payment":"payments"}`,detail:"Choose who was paid, or mark the transfer as unrelated to contractors.",href:"/",verb:"Identify"});for(let J of I.timesheetPayments?.items??[])D.push({id:`timesheet-payment-${J.id}`,label:J.title,detail:J.detail,href:"/",verb:"Review"});return D}}),Q)B.push({label:"Your checklist",reads:[{action:"compliance.items.list",input:{status:"open",assigneeUserId:Q,limit:3}}],items:([E])=>E.items.filter((I)=>!["done","skipped"].includes(I.status)).map((I)=>({id:`assigned-${I.id}`,label:I.title,detail:"Assigned to you",href:`/checklist?item=${I.id}`}))});if(B.push({label:"Wise setup",reads:[{action:"wise.status",input:{}}],items:([E])=>{return E.ready?[]:[{id:"wise-setup",label:A==="admin"?"Set up Wise":"Wise setup needs an admin",detail:A==="admin"?"Connect and sync history":"Ask an administrator to connect it",href:A==="admin"?"/settings?section=connections":"/finance/transactions",verb:A==="admin"?"Set up":"Open"}]}},...A==="admin"||A==="finance"?[{label:"Accountant questions",reads:[{action:"accountants.comments.list",input:{status:"active",limit:5}}],items:([E])=>{let I=E.openTotal??0,D=A==="admin"?E.pendingChanges??0:0;return[...I>0?[VQQ(I)]:[],...D>0?[_QQ(D)]:[]]}}]:[],{label:"Compliance deadlines",reads:[{action:"compliance.checklist",input:{includeDone:!1}}],items:([E])=>{let I=E,D=I.summary?.overdue??0,J=I.summary?.dueSoon??0;if(!D&&!J)return[];return[{id:"compliance-deadlines",label:D?"Review overdue deadlines":"Review upcoming deadlines",detail:[D?`${D} overdue`:null,J?`${J} due within 14 days`:null].filter(Boolean).join(" · "),href:"/checklist",verb:"Review"}]}}),B.push({label:"New people",reads:[{action:"notifications.joins.list",input:{}}],items:([E])=>xXA(E)}),B.push({label:"Snoozed items",reads:[{action:"notifications.checklist.list",input:{}}],items:([E])=>fXA(E)}),A==="admin"||A==="finance")B.push({label:"Document comments",reads:[{action:"notifications.comments.list",input:{}}],items:([E])=>E.items.map((I)=>({id:`doc-comment-${I.id}`,label:I.label,detail:I.detail,href:I.href,verb:"Review"}))});return B}function VZA(A,Q){let B=LQQ[A]??[];return OQQ(A,Q).filter((E)=>!B.includes(E.label))}function _ZA(A,Q){let B=0,E=[],I=[],D=[];for(let J of A){let G=Q.slice(B,B+J.reads.length);if(B+=J.reads.length,G.length<J.reads.length||G.some((U)=>U.status==="loading")){D.push(J.label);continue}if(G.some((U)=>U.status==="failed")){I.push(J.label);continue}try{if(E.push(...J.items(G.map((U)=>U.data))),G.some((U)=>U.status==="stale"))I.push(J.label)}catch{I.push(J.label)}}return{items:E,unavailable:I,loading:D}}var dAQ,hU,iAQ,nAQ,aAQ,oAQ,rAQ,eAQ,eXA,BZA,SD,IQQ,EQQ,EZA,lh,GZA,GQQ,$QQ,UZA,HZA,XZA,YQQ,ZQQ,FZA="/legal/agreements/write",MQQ,LQQ;var mU=W(()=>{iH();Ph();kXA();yXA();uXA();yh();oXA();ch();dAQ=[{id:"ops",label:"Ops"},{id:"finance",label:"Finance"},{id:"legal",label:"Legal"},{id:"people",label:"People"},{id:"insights",label:"Insights"}],hU={home:"/",chiefOfStaff:fh,inbox:"/inbox",checklist:"/checklist",calendar:"/calendar",ai:"/ai",financeAi:"/finance/ai",peopleAi:"/people/ai",legalAi:"/legal/ai",insightsAi:"/insights/ai",compliance:"/compliance",logs:"/logs",history:"/history",developers:"/developers",godMode:z$,settings:"/settings",transactions:"/finance/transactions",reconcile:"/finance/reconcile",invoices:"/finance/invoices",tax:"/finance/tax",financialStatements:"/finance/financial-statements",taxInfo:"/finance/tax/info",reports:"/finance/reports",insights:"/insights",reimbursements:"/finance/reimbursements",subscriptions:"/finance/subscriptions",budgets:"/finance/budgets",documents:"/legal/agreements",people:"/people/recruiting",contractors:"/people/contractors"},iAQ={"/finance":"transactions","/legal":"documents","/people":"people"};nAQ={home:"Home",chiefOfStaff:"Chief of Staff",inbox:"Inbox",checklist:"Checklist",calendar:"Calendar",invoices:"Invoices",documents:"Agreements",transactions:"Transactions",reconcile:"Reconcile",reports:"Reports",insights:"Insights",reimbursements:"Reimbursements",subscriptions:"Subscriptions",budgets:"Budgets",contractors:"Contractors",people:"People",tax:"Tax preparation",taxInfo:"Tax info",financialStatements:"Financial statements",ai:"Autopilot",financeAi:"Finance AI",peopleAi:"People AI",legalAi:"Legal AI",insightsAi:"Insights AI",compliance:"Compliance",logs:"Logs",history:"History",developers:"Developers",godMode:"God Mode",settings:"Settings"};aAQ={matching:"Receipt matching",stripe:"Stripe payouts",bank:"Bank transactions"},oAQ={accounts:"Accounts and imports",projects:"Projects",merchants:"Merchants",trips:"Trips",statements:"Statements"},rAQ={reconcile:({search:A})=>aAQ[NQQ("reconcile",A)],transactions:({search:A})=>oAQ[A.get("view")??""],ai:({search:A,role:Q,platformOwner:B})=>Q?DQQ(DZA(A.get("view"),Q,B===!0)):void 0,compliance:({search:A})=>CQQ(CZA(A.get("view"))),chiefOfStaff:({search:A})=>{let Q=uh(A.get("view"));return Q==="overview"?void 0:`Chief of Staff · ${nXA(Q)}`},developers:({search:A,role:Q})=>Q?pXA(xh(A.get("view"),Q)):void 0,inbox:({search:A,role:Q})=>Q?BQQ(IZA(A,Q)):void 0,tax:({search:A})=>A.get("view")==="records"?"Tax records":A.get("view")==="workpaper"?"Detailed workpaper":A.get("view")==="stripe"?"Stripe for the year":A.get("view")==="shareholders"?"Shareholders":void 0,documents:({search:A})=>{if(A.get("envelope"))return"";let Q=ZZA(A.get("view"));return Q==="all"?void 0:KQQ(Q)},people:({search:A,role:Q})=>Q?UQQ(YZA(A.get("view"),Q)):void 0,contractors:({search:A})=>sAQ(A.get("view")),invoices:({search:A})=>bh(A).heading,insights:({search:A})=>{let Q=AZA(A.get("view"));return`Insights · ${Q[0].toUpperCase()}${Q.slice(1)}`}};eAQ=["overview","signups","workspaces","experiments"];eXA=["finance","people","projects","tax","map"];BZA=[{key:"accounting",label:"Accounting"},{key:"invoices",label:"Invoices"},{key:"signatures",label:"Signatures"},{key:"contractors",label:"Contractors"},{key:"reminders",label:"Reminders"},{key:"notifications",label:"Notifications"}],SD={receipts:"Receipts and invoices",email:"All email",quarantine:"Quarantine",connected:"Connected inboxes",mine:"My receipts",uploads:"Uploads",ai:"AI settings"};IQQ=["overview","agents","classifiers","playground","memory","connections","settings"],EQQ=["classifiers","memory","settings"],EZA={overview:"Overview",classifiers:"Classifiers",playground:"Try it",memory:"Memory",agents:"Agents",connections:"Connections",settings:"AI settings"};lh={"gst-hst":"GST/HST return",slips:"Contractor slips (T4A)",t2:"Corporate tax (T2)"};GZA=["ask","library","items","research"],GQQ={ask:"Ask",library:"Library",items:"Open items",research:"Research"};$QQ=["postings","interviews","board"],UZA={postings:"Job postings",interviews:"My interviews",board:"Job board"};HZA=["all","contracts","jobs","templates"],XZA={all:"All agreements",contracts:"Contracts",jobs:"Jobs",templates:"Templates"},YQQ={contractors:"contracts"};ZQQ=new Set(["people","contractors","peopleAi"]);MQQ={action:"requests.list",input:{mine:!0,status:"open",limit:50}};LQQ={admin:["Receipt review","Snoozed items"],finance:["Receipt review","Wise setup","Snoozed items"],contributor:[]}});function F$(A){let Q=new URL(A,"https://oatmilk.invalid"),B=Q.pathname.length>1?Q.pathname.replace(/\/+$/,""):Q.pathname;return{href:`${B}${Q.search}`,path:B,params:Q.searchParams}}function LZA(A){return OD(A.href)??""}function cU(A,Q){return Q.startsWith("/cli/")?A:`${A}${Q}`}function jQQ(A){if(A==="/ops")return"/";return A.startsWith("/ops/")?A.slice(4):A}function WZA(A,Q){let{params:B}=A,E=jQQ(A.path),I=B.get("view");if(E===D1)return{kind:"actions"};if(E===WQQ)return{kind:"chat"};if(E==="/")return{kind:"home"};if(E==="/inbox"){if(I==="connected")return{kind:"page"};if(Q==="contributor"||I==="receipts"||I==="uploads")return{kind:"list",list:I==="uploads"?"uploads":"receipts",recordId:B.get("submission")??void 0};return{kind:"list",list:"email",recordId:B.get("mail")??void 0}}if(E==="/checklist")return{kind:"list",list:"checklist",recordId:B.get("item")??void 0};if(E==="/settings")return{kind:"settings"};if(E==="/finance"||E==="/finance/transactions"){if(I==="accounts")return{kind:"list",list:"accounts"};if(I==="merchants"||I==="trips"||I==="statements"){if(!OZA(Q))return{kind:"page"};let J=I==="merchants"?"merchant":I==="trips"?"trip":"statement";return{kind:"list",list:I,recordId:B.get(J)??void 0}}if(I&&I!=="all")return{kind:"page"};return{kind:"list",list:"transactions",recordId:B.get("entry")??void 0}}if(E==="/finance/reconcile"){if(I==="bank")return{kind:"list",list:"bank"};if(I==="stripe")return{kind:"list",list:"stripe"};return{kind:"list",list:"matching"}}if(E==="/finance/invoices")return I==="scheduled"||I==="accounts"?{kind:"page"}:{kind:"list",list:"invoices",recordId:B.get("invoice")??void 0};if(E==="/finance/reimbursements")return{kind:"list",list:"reimbursements"};if(E==="/finance/subscriptions")return{kind:"list",list:"subscriptions"};if(E==="/finance/reports")return{kind:"report"};if(E==="/finance/tax")return I==="records"?{kind:"page"}:{kind:"tax"};if(E==="/insights")return!I||I==="finance"?{kind:"insights"}:{kind:"page"};if(E==="/legal"||E==="/legal/agreements")return I==="templates"?{kind:"page"}:{kind:"list",list:"agreements"};let D=/^\/legal\/agreements\/([0-9a-f-]{36})$/i.exec(E);if(D)return{kind:"list",list:"agreements",recordId:D[1]};if(E==="/history")return OZA(Q)?{kind:"list",list:"history",recordId:B.get("event")??void 0}:{kind:"page"};if(E==="/compliance")return I==="items"&&Q==="admin"?{kind:"list",list:"compliance-items"}:{kind:"page"};if(E==="/developers")return I==="webhooks"&&Q==="admin"?{kind:"list",list:"webhooks"}:{kind:"page"};if(E==="/people"||E==="/people/recruiting")return I==="interviews"||I==="board"?{kind:"page"}:{kind:"list",list:"postings"};if(E==="/people/contractors"){if(I==="timesheets")return{kind:"list",list:"timesheets"};if(!I||I==="directory")return{kind:"list",list:"contractors",recordId:B.get("contractor")??void 0};return{kind:"page"}}return{kind:"page"}}var D1="/cli/actions",WQQ="/cli/chat",OZA=(A)=>A==="admin"||A==="finance";var qG=W(()=>{l1()});function jZA(){let{identity:A,route:Q,layout:B,session:E,role:I,update:D,askAi:J}=FB(),G=uU(Q.path),U=Q.path===D1?"Run an action":_M({view:G,search:Q.params,role:I})||"Oatmilk",Y=A.workspaceKind==="personal"?"Personal":A.organizationName??"Your company",H=B.columns>=100?"⌃K jump ⌃O chat ? keys":"⌃K ?";return d(e,{width:B.columns,height:1,overflow:"hidden",paddingX:1,children:[R(e,{flexGrow:1,flexShrink:1,overflow:"hidden",children:d(f,{wrap:"truncate-end",children:[d(f,{color:L.accent,bold:!0,children:[hA.brand," oatmilk"]}),R(f,{color:L.faint,children:" │ "}),R(f,{color:L.text,bold:!0,children:U}),R(f,{color:L.faint,children:" │ "}),R(f,{color:L.text,children:Y}),d(f,{color:L.muted,children:[" · ",I]}),E.host!=="https://app.getoatmilk.com"?d(f,{color:L.warning,children:[" · ",TI(E.host)]}):null,J.kind==="local"?d(f,{color:L.muted,children:[" · ",R(f,{color:L.accent,children:hA.ai})," ",J.model]}):null]})}),d(e,{flexShrink:0,marginLeft:2,children:[D?d(f,{color:D.state==="available"?L.accent:L.muted,children:[D.state==="available"?`${hA.update} ${D.offer.latest.version} ⌃U`:D.state==="installing"?`Updating to ${D.offer.latest.version}…`:`Restart for ${D.offer.latest.version}`," "]}):null,R(f,{color:L.faint,children:H})]})]})}var RZA=W(async()=>{mU();F1();qG();BE();bB();HQ();await dB()});function lU(A,Q=Date.now()){let B=Math.round((Q-Date.parse(A))/60000);if(!Number.isFinite(B)||B<1)return"just now";if(B<60)return`${B} min ago`;let E=Math.round(B/60);if(E<24)return`${E} h ago`;let I=Math.round(E/24);return I===1?"yesterday":`${I} days ago`}function RQQ(A,Q){let B=[...A.replace(/\s+/g," ")];if(Q<=0)return"";return B.length<=Q?B.join(""):`${B.slice(0,Math.max(0,Q-1)).join("")}…`}function uI(A,Q,B="left"){let E=RQQ(A,Q),I=[...E].length,D=" ".repeat(Math.max(0,Q-I));return B==="right"?`${D}${E}`:`${E}${D}`}var d1=W(()=>{iH()});function zE({rows:A=6,width:Q,columns:B,label:E}){let{frame:I}=x1({interval:120}),D=I%(A+6);return R(e,{flexDirection:"column","aria-label":E,children:Array.from({length:A},(J,G)=>{let U=Math.abs(G-D+3)<=1?L.border:L.skeleton;if(B?.length)return R(f,{color:U,children:B.map((Y,H)=>`${"▆".repeat(Math.max(2,Math.round(Y*(H===1?OM[(G+H)%OM.length]+0.3:0.8))))}`.padEnd(Y+2)).join("")},G);return R(f,{color:U,children:"▆".repeat(Math.max(4,Math.floor(Q*OM[G%OM.length])))},G)})})}var OM;var FG=W(async()=>{bB();HQ();await dB();OM=[0.62,0.48,0.71,0.55,0.66,0.41,0.58,0.69]});function gZA({width:A,height:Q,onClose:B}){iQ((I,D)=>{if(D.escape||D.return||I==="?"||I==="q")B()});let E=Math.min(84,A-4);return R(e,{position:"absolute",top:0,left:0,width:A,height:Q,alignItems:"center",justifyContent:"center",children:d(e,{flexDirection:"column",width:E,borderStyle:"single",borderColor:L.focus,paddingX:2,paddingY:1,backgroundColor:L.panel,children:[R(f,{bold:!0,children:"Keys"}),gQQ.slice(0,Math.max(4,Q-6)).map(([I,D])=>D?d(f,{wrap:"truncate-end",children:[R(f,{color:L.accent,children:I.padEnd(34)}),R(f,{color:L.muted,children:D})]},I):R(f,{color:L.faint,bold:!0,children:I.toUpperCase()},I)),R(f,{color:L.faint,children:"Esc to close · docs: getoatmilk.com/docs/terminal"})]})})}function dh({title:A,width:Q,height:B,items:E,loading:I,error:D,render:J,onPick:G,onClose:U,empty:Y}){let[H,X]=J1.useState(0);iQ((V,O)=>{if(O.escape)U();else if(O.upArrow||V==="k")X((j)=>Math.max(0,j-1));else if(O.downArrow||V==="j")X((j)=>Math.min(E.length-1,j+1));else if(O.return&&E[H])G(E[H])});let N=Math.min(80,Q-4),z=Math.max(3,B-8),F=Math.max(0,Math.min(H-Math.floor(z/2),E.length-z));return R(e,{position:"absolute",top:0,left:0,width:Q,height:B,alignItems:"center",justifyContent:"center",children:d(e,{flexDirection:"column",width:N,borderStyle:"single",borderColor:L.focus,paddingX:2,paddingY:1,backgroundColor:L.panel,children:[R(f,{bold:!0,children:A}),I?R(zE,{rows:3,width:N-8,label:A}):D?R(f,{color:L.danger,children:D}):!E.length?R(f,{color:L.muted,children:Y}):E.slice(F,F+z).map((V,O)=>{let[j,b]=J(V),x=F+O===H;return d(e,{justifyContent:"space-between",children:[d(f,{color:x?L.focus:L.text,wrap:"truncate-end",children:[x?hA.pointer:" "," ",j]}),d(f,{color:L.faint,children:[" ",b]})]},F+O)}),R(f,{color:L.faint,children:"↑↓ choose · ⏎ open · Esc close"})]})})}function TZA({width:A,height:Q,onClose:B}){let E=FB(),[I,D]=J1.useState([]),[J,G]=J1.useState({loading:!0,error:null});return J1.useEffect(()=>{UG(E.session).then((U)=>{D(U),G({loading:!1,error:null})},(U)=>G({loading:!1,error:CQ(U)}))},[E.session]),R(dh,{title:"Recent chats",width:A,height:Q,items:I,loading:J.loading,error:J.error,empty:"No earlier chats yet.",render:(U)=>[U.title,lU(U.updatedAt)],onClose:B,onPick:(U)=>{B(),E.chat.start(U.sessionId),E.setChatVisible(!0),E.setFocus("composer")}})}function PZA({width:A,height:Q,onClose:B}){let E=FB(),I=E.session.kind==="api_key",[D,J]=J1.useState(E.organizations),[G,U]=J1.useState({loading:!I&&!E.organizations.length,error:null}),Y=I?{loading:!1,error:"An API key belongs to one workspace. Sign in with your browser to switch."}:G;J1.useEffect(()=>{if(I)return;PC(E.session).then((N)=>{J(N),U({loading:!1,error:null})},(N)=>U({loading:!1,error:CQ(N)}))},[E.session,I]);let H=TQQ(D,I);async function X(N){if(B(),N.organizationId){await E.switchOrganization(N.organizationId);return}try{let z=await OK(E.session);await E.switchOrganization(z.organizationId)}catch(z){E.toast(CQ(z),"danger")}}return R(dh,{title:"Switch workspace",width:A,height:Q,items:H,loading:Y.loading,error:Y.error,empty:"You can open only this workspace.",render:(N)=>[`${N.organizationId&&N.organizationId===E.identity.organizationId?"● ":""}${Jz(N)}`,N.organizationId?N.kind==="personal"?"just you":N.role:"set up"],onClose:B,onPick:(N)=>void X(N)})}function TQQ(A,Q){let B=A.filter((D)=>D.kind==="personal"),E=A.filter((D)=>D.kind!=="personal").sort((D,J)=>D.name.localeCompare(J.name)),I=!B.length&&!Q&&A.length?[{organizationId:"",name:"Personal",role:"",current:!1,kind:"personal"}]:[];return[...B,...I,...E]}function SZA({width:A,height:Q,onClose:B}){let E=FB(),[I,D]=J1.useState([]),[J,G]=J1.useState({loading:!0,error:null});J1.useEffect(()=>{p4().then((Y)=>{D(_z(Y)),G({loading:!1,error:null})},(Y)=>G({loading:!1,error:CQ(Y)}))},[]);let U=!J.loading&&I.length===1;return R(dh,{title:U?"Ask AI uses Oatmilk's AI. Start Ollama or LM Studio to use a model here.":"Where should Ask AI think?",width:A,height:Q,items:I,loading:J.loading,error:J.error,empty:"",render:(Y)=>[`${Av(Y.choice,E.askAi)?`${hA.done} `:""}${Y.label}`,Y.detail],onClose:B,onPick:(Y)=>{if(B(),!Av(Y.choice,E.askAi))E.setAskAi(Y.choice).catch((H)=>E.toast(CQ(H),"danger"))}})}var J1,gQQ;var wZA=W(async()=>{PU();wQ();d1();SC();fJ();xJ();BE();bB();HQ();await $0([dB(),FG()]);J1=pA(JQ(),1),gQQ=[["Everywhere",""],["⌃K","Jump to a page, find a record, run an action"],["⌃O","Show or hide Ask AI"],["⌃G","Open the page Ask AI offered"],["Tab / ⇧Tab","Move between the sidebar, the page and the message box"],["/theme","Change the theme (it follows your terminal's light or dark)"],["/model","Where Ask AI thinks: Oatmilk, or a model on this computer"],["⌃U or /update","Update oatmilk when a new version is out"],["⌃C twice","Quit"],["Lists",""],["↑↓ j k · PgUp PgDn · g G","Move"],["⏎ or →","Open the record beside the list"],["Esc or ←","Close it, or go back to the sidebar"],["/","Search this list"],["[ ]","Previous or next view (Needs you, Done…)"],["i","Ask AI about the highlighted record"],["o · y","Open in the browser · copy its link"],["R","Refresh"],["Letters","The record's actions, shown at the bottom (a approve, c categorize…)"],["Message box",""],["⏎","Send · ⌥⏎ or ⌃J for a new line"],["↑ ↓","Earlier messages, or the answers to Ask AI's question"],["PgUp PgDn","Scroll the chat"],["/new /chats /org /run /go /logout","Commands"],["Esc","Stop Ask AI, or go back to the page"]]});function bZA(A){return typeof A==="string"?{kind:A,experimental:!1}:{kind:A.kind??"company",experimental:A.experimental===!0}}function aH(A,Q="company"){let{kind:B,experimental:E}=bZA(Q),I=PQQ.filter((D)=>(B!=="personal"||!vQQ.has(D.id))&&(E||D.group!=="experimental"));if(A==="admin")return I;if(A==="contributor")return I.filter((D)=>D.group==="experimental");return I.filter((D)=>!wQQ.includes(D.id))}function kZA(A,Q="company"){let{kind:B}=bZA(Q),E=new Set(aH(A,Q).map((I)=>I.group));if(A==="contributor")return[{id:"developer",label:"Developer"},...E.has("experimental")?[{id:"experimental",label:vZA("experimental",B)}]:[]];return ih.filter((I)=>E.has(I)).map((I)=>({id:I,label:vZA(I,B)}))}function vZA(A,Q="company"){return(Q==="personal"?bQQ[A]:void 0)??SQQ[A]}var ih,PQQ,SQQ,wQQ,vQQ,bQQ;var nh=W(()=>{yh();ih=["company","reminders","people","money","email","ai","developer","experimental"],PQQ=[{id:"organization",label:"Details",title:"Company details",group:"company"},{id:"categories",label:"Categories",title:"Categories",group:"company"},{id:"documents",label:"Invoices",title:"Invoice settings",group:"company"},{id:"data",label:"Your data",title:"Your data",group:"company"},{id:"reminders",label:"Emails",title:"Reminder emails",group:"reminders"},{id:"receipt-reminders",label:"Receipts",title:"Receipt reminders",group:"reminders"},{id:"deadlines",label:"Deadlines",title:"Deadlines and filings",group:"reminders"},{id:"regulations",label:"Tax rules",title:"Tax rule changes",group:"reminders"},{id:"people",label:"Team",title:"Team members",group:"people"},{id:"accountants",label:"Accountants",title:"Accountant access",group:"people"},{id:"joining",label:"Alerts",title:"New people alerts",group:"people"},{id:"connections",label:"Banks and payments",title:"Bank connections",group:"money"},{id:"mail",label:"Addresses",title:"Email addresses",group:"email"},{id:"senders",label:"Senders",title:"Approved senders",group:"email"},{id:"email-types",label:"Sorting",title:"Email sorting",group:"email"},{id:"sending",label:"Sending",title:"Sending addresses",group:"email"},{id:"ai-keys",label:"AI keys",title:"AI keys",group:"ai"},{id:"connectors",label:"Connectors",title:"Data connectors",group:"developer"},{id:"experiments",label:"Experiments",title:"Experimental features",group:"experimental"}],SQQ={company:"Company",reminders:"Reminders",people:"People",money:"Banks and payments",email:"Email",ai:"AI keys",developer:"Developer",experimental:"Experimental"},wQQ=["organization","documents","data","reminders","receipt-reminders","deadlines","regulations","people","accountants","joining","connections","mail","senders","email-types","sending","ai-keys","connectors"];vQQ=new Set(["people","joining"]);bQQ={company:"Workspace",people:"Accountants"}});function LM(A,Q={}){let B=A==="owner"?"/finance/financial-statements":"/accountant/financial-statements",E=new URLSearchParams;if(Q.period)E.set("from",Q.period.from),E.set("to",Q.period.to);if(Q.report)E.set("report",Q.report);if(Q.send)E.set("send","1");if(Q.packages)E.set("packages","1");if(Q.review)E.set("review","1");let I=E.toString();return I?`${B}?${I}`:B}function kQQ(A){return[["balance_sheet","Balance sheet"],["income_statement","Income statement"],["trial_balance","Trial balance"],["general_ledger","General ledger"],["gst_hst","GST/HST summary"],...A?[]:[["contractors","Contractors and T4A slips"]]].map(([B,E])=>({id:`fs:${B}`,label:E,parent:"Financial statements",href:LM("owner",{report:B}),kind:"view",area:"financialStatements",keywords:$B[`fs:${B}`]??[]}))}function wD(A){if(!A)return[];let Q=A.id==="ai"?"ai":A.id;return A.groups.flatMap((B)=>B.links.map((E)=>{let I=E.id.startsWith("mailbox-")?E.id.slice(8):null;return{id:`${A.id}:${E.id}`,label:A.id==="insights"&&E.id==="tax"?"Tax workpaper":E.label,parent:I?"Inbox · Mailboxes":xQQ[A.id],href:E.href,kind:"view",area:Q,keywords:I?["mailbox",`${I} mail`,`${I} email`]:$B[`${A.id}:${E.id}`]??[]}}))}function yZA(A,Q=!1,B="company"){let E=A==="admin",I=A!=="contributor",D=B==="personal",J=q$(A,Q,B),G=(Y)=>J.some((H)=>H.id===Y),U=J.map((Y)=>({id:`page:${Y.id}`,label:Y.label,href:Y.href,kind:"page",area:Y.id,keywords:$B[`page:${Y.id}`]??[]}));if(G("budgets"))U.push({id:"budgets:spending",label:"Spending plans",parent:"Budgets",href:"/finance/budgets?part=spending",kind:"view",area:"budgets",keywords:["budget","monthly spending","category limit","plan"]},{id:"budgets:reserves",label:"Reserve accounts",parent:"Budgets",href:"/finance/budgets?part=reserves",kind:"view",area:"budgets",keywords:["wise reserve","hst account","tax account","set aside","account purpose"]});if(U.push(...wD(E1("transactions",A))),U.push(...wD(E1("inbox",A,!1,B))),U.push(...wD(E1("ai",A))),G("developers"))U.push(...wD(E1("developers",A)));if(G("chiefOfStaff"))U.push(...wD(E1("chiefOfStaff",A,Q)).filter((Y)=>Y.id!=="chiefOfStaff:overview"));if(U.push(...wD(E1("compliance",A,Q))),U.push(...wD(E1("people",A,!1,B)).filter((Y)=>Y.href?.startsWith("/people/recruiting"))),U.push(...wD(E1("insights",A))),U.push(...wD(E1("invoices",A)).map((Y)=>Y.id==="invoices:archived"?{...Y,label:"Archived invoices"}:Y.id==="invoices:archived_accounts"?{...Y,label:"Archived customers and vendors"}:Y.id==="invoices:scheduled"?{...Y,label:"Scheduled invoices"}:Y)),G("contractors"))U.push(...nH.filter((Y)=>Y.view!=="settings"||E).map((Y)=>({id:`contractors:${Y.view}`,label:Y.label,parent:"Contractors",href:Y.href,kind:"view",area:"contractors",keywords:$B[`contractors:${Y.view}`]??[]})));if(U.push(...kZA(A,B).map((Y)=>({id:`settings:${Y.id}`,label:Y.label,parent:"Settings",href:`/settings?section=${Y.id}`,kind:"setting",area:"settings",keywords:$B[D&&Y.id==="people"?"settings:accountants":`settings:${Y.id}`]??[]}))),U.push(...aH(A,B).filter((Y)=>!ih.includes(Y.id)).map((Y)=>({id:`settings:${Y.id}`,label:Y.title,parent:"Settings",href:`/settings?section=${Y.id}`,kind:"setting",area:"settings",keywords:$B[`settings:${Y.id}`]??[]}))),I)U.push({id:"documents:all",label:"All agreements",parent:"Agreements",href:"/legal/agreements",kind:"view",area:"documents",keywords:$B["documents:all"]},...D?[]:[{id:"documents:contracts",label:"Contracts",parent:"Agreements",href:"/legal/agreements?view=contracts",kind:"view",area:"documents",keywords:$B["documents:contracts"]},{id:"documents:jobs",label:"Jobs",parent:"Agreements",href:"/legal/agreements?view=jobs",kind:"view",area:"documents",keywords:$B["documents:jobs"]}],{id:"documents:templates",label:"Agreement templates",parent:"Agreements",href:"/legal/agreements?view=templates",kind:"view",area:"documents",keywords:$B["documents:templates"]},{id:"checklist:calendar",label:"Calendar",parent:"Checklist",href:"/calendar",kind:"view",area:"checklist",keywords:$B["checklist:calendar"]},{id:"reports:stripe",label:"Stripe activity",parent:"Reports",href:"/finance/reports?view=stripe",kind:"view",area:"reports",keywords:$B["reports:stripe"]},{id:"tax:info",label:"Tax info",parent:"Taxes",href:"/finance/tax/info",kind:"view",area:"taxInfo",keywords:$B["tax:info"]},{id:"tax:prep",label:"Year-end",parent:"Taxes",href:"/finance/tax",kind:"view",area:"tax",keywords:$B["tax:prep"]},{id:"tax:corporate",label:"Corporate tax (T2)",parent:"Taxes",href:"/finance/tax?kind=corporate",kind:"view",area:"tax",keywords:$B["tax:corporate"]},{id:"tax:gst",label:"GST/HST return",parent:"Taxes",href:"/finance/tax?kind=gst_hst",kind:"view",area:"tax",keywords:$B["tax:gst"]},{id:"tax:setup",label:"Company and tax setup",parent:"Taxes",href:"/finance/tax/setup",kind:"view",area:"tax",keywords:$B["tax:setup"]},...kQQ(D),{id:"tax:stripe",label:"Stripe for the year",parent:"Taxes",href:"/finance/tax?view=stripe",kind:"view",area:"tax",keywords:$B["tax:stripe"]},{id:"tax:records",label:"Tax records",parent:"Taxes",href:"/finance/tax?view=records",kind:"view",area:"tax",keywords:$B["tax:records"]},{id:"tax:shareholders",label:"Shareholders",parent:"Taxes",href:"/finance/tax?view=shareholders",kind:"view",area:"tax",keywords:$B["tax:shareholders"]},{id:"tax:file-gst",label:"File your GST/HST return",parent:"Taxes",href:"/finance/tax?view=gst-hst",kind:"view",area:"tax",keywords:$B["tax:file-gst"]},{id:"tax:file-t2",label:"File your corporate tax return (T2)",parent:"Taxes",href:"/finance/tax?view=t2",kind:"view",area:"tax",keywords:$B["tax:file-t2"]},...D?[]:[{id:"tax:file-slips",label:"File contractor slips (T4A)",parent:"Taxes",href:"/finance/tax?view=slips",kind:"view",area:"tax",keywords:$B["tax:file-slips"]}]);if(U.push({id:"action:upload",label:"Add receipt",kind:"action",area:"inbox",run:"upload",keywords:$B["action:upload"]}),U.push({id:"action:intake",label:"Upload files",kind:"action",area:"inbox",run:"intake",keywords:$B["action:intake"]}),I)U.push({id:"action:import",label:"Import bank CSV",kind:"action",area:"transactions",run:"import",keywords:$B["action:import"]},{id:"action:invoice",label:"Create an invoice",kind:"action",area:"invoices",href:"/finance/invoices/new",keywords:$B["action:invoice"]},{id:"action:sign",label:"Send a document for signature",kind:"action",area:"documents",href:"/legal/agreements/new",keywords:$B["action:sign"]},...D?[]:[{id:"action:contractor",label:"Add a contractor",kind:"action",area:"contractors",href:"/people/contractors?new=contractor",keywords:$B["action:contractor"]}]);if(A==="admin"||A==="finance")U.push({id:"action:sendAccountant",label:"Send to your accountant",kind:"action",area:"financialStatements",href:LM("owner",{send:!0}),keywords:$B["action:sendAccountant"]},{id:"fs:packages",label:"Packages you sent",parent:"Financial statements",href:LM("owner",{packages:!0}),kind:"view",area:"financialStatements",keywords:$B["fs:packages"]});if(E)U.push({id:"action:accountant",label:"Invite your accountant",kind:"action",area:"settings",href:"/settings?section=accountants&invite=accountant",keywords:$B["action:accountant"]},...D?[]:[{id:"action:members",label:"Invite a teammate",kind:"action",area:"settings",href:"/settings?section=people",keywords:$B["action:members"]}]);return U.push(...G("developers")?[{id:"action:apiKey",label:"Create an API key",kind:"action",area:"developers",href:"/developers?view=keys&new=key",keywords:$B["action:apiKey"]}]:[],{id:"action:inbox",label:"Connect Gmail or Outlook",kind:"action",area:"inbox",href:"/inbox?view=connected",keywords:$B["action:inbox"]}),U}function oH(A){return A.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLocaleLowerCase().replace(/&/g," and ").replace(/[^a-z0-9]+/g," ").trim()}function yQQ(A,Q){let B=0;for(let E of A){if(B=Q.indexOf(E,B),B<0)return!1;B+=1}return!0}function WM(A,Q){let B=oH(Q);if(!B)return 1;let E=oH(A.label),I=oH(A.parent??""),D=A.keywords.map(oH);if(E===B)return 100;if(E.startsWith(B))return 90;if(D.includes(B))return 85;if(E.split(" ").some((G)=>G.startsWith(B)))return 80;if(D.some((G)=>G.startsWith(B)))return 75;if(D.some((G)=>G.split(" ").some((U)=>U.startsWith(B))))return 70;let J=B.split(" ");if(J.length>1){let G=E.split(" "),U=D.flatMap((X)=>X.split(" ")),Y=I.split(" ").filter(Boolean),H=0;for(let X of J){let N=G.includes(X)?3:G.some((z)=>z.startsWith(X))?2:U.includes(X)?2:U.some((z)=>z.startsWith(X))||Y.some((z)=>z.startsWith(X))?1:0;if(!N){H=-1;break}H+=N}if(H>0)return Math.min(69,55+H)}if(E.includes(B))return 50;if(B.length>=4&&J.length===1&&[E.replaceAll(" ",""),...D.map((G)=>G.replaceAll(" ",""))].some((G)=>yQQ(B,G)))return 20;return 0}function fZA(A,Q,B=12){if(!oH(Q))return A.filter((E)=>E.kind==="page"||E.kind==="action");return A.map((E,I)=>({entry:E,position:I,score:WM(E,Q)})).filter((E)=>E.score>0).sort((E,I)=>I.score-E.score||xZA[E.entry.kind]-xZA[I.entry.kind]||E.position-I.position).slice(0,B).map((E)=>E.entry)}var $B,xQQ,xZA;var hZA=W(()=>{mU();nh();$B={"page:home":["dashboard","overview","start","needs you","today","to do","todo","tasks"],"page:inbox":["email","mail","messages","receipts","forwarded","documents"],"page:transactions":["expenses","spending","purchases","payments","bank","card","ledger","books","entries","bookkeeping"],"page:invoices":["billing","bills","receivables","sales","customers","accounts receivable","quotes"],"page:documents":["documents","contracts","sign","signature","e-sign","esign","nda","envelopes","docusign"],"page:people":["recruiting","hiring","jobs","candidates","applicants","ats","interviews"],"people:postings":["job posting","jobs","hiring","recruiting","candidates","applicants","pipeline","open role"],"people:interviews":["interview","scorecard","feedback","candidates"],"people:board":["careers page","job board","public jobs","careers"],"page:contractors":["freelancers","consultants","workers","people","vendors","timesheets","hours","payouts","payroll"],"page:checklist":["compliance","deadlines","due dates","filings","reminders","to do","todo","tasks","cra"],"page:taxInfo":["tax","taxes","gst","hst","sales tax","t2","corporate tax","income tax","cra","returns","filing","tax prep"],"page:budgets":["budget","budgeting","spending plan","reserve","reserves","set aside","tax savings","cash coverage"],"page:reports":["summary","money in","money out","cash","export","analytics","spending report"],"page:financialStatements":["financial statements","statements","accountant","reports for your accountant","accountant reports","year-end reports","excel","pdf","gifi","download statements"],"fs:balance_sheet":["assets","liabilities","equity","net worth","what we own"],"fs:income_statement":["profit and loss","p&l","pnl","profit","loss","revenue","expenses","net income","earnings"],"fs:trial_balance":["debits","credits","tb","accounts"],"fs:general_ledger":["ledger","gl","postings","journal"],"fs:gst_hst":["gst report","hst report","sales tax report","gst summary","itc","input tax credits"],"fs:contractors":["t4a list","contractor report","contractor payments","t4a slips"],"fs:packages":["sent packages","who downloaded","package links","packages sent"],"page:insights":["analytics","trends","spend","people cost","projects","tax"],"insights:finance":["spend","revenue","income","profit","loss","categories"],"insights:people":["contractor cost","hours","punctuality","timesheets"],"insights:projects":["project costs","tags","overlap"],"insights:tax":["gst","hst","readiness","workpaper"],"insights:map":["world map","locations","city counts","geography","venue map","transaction map"],"page:ai":["autopilot","automation","jobs","assistant","machine learning","run ai"],"page:chiefOfStaff":["chief of staff","discord","bot","agent","server","channels","permissions","rules","community"],"chiefOfStaff:server":["discord server","channels","channel rules","per channel","replies","mentions only"],"chiefOfStaff:people":["discord roles","permissions","people rules","access","organizers"],"chiefOfStaff:tools":["discord tools","luma","guest lists","web search","github","access","integrations"],"chiefOfStaff:schedules":["scheduled posts","cron","good morning","ai news","pause posts"],"chiefOfStaff:activity":["discord metrics","tokens","requests","gateway"],"chiefOfStaff:settings":["pause chief of staff","direct messages","ignore people","block"],"page:compliance":["compliance","legal","hiring","job posting","contractor","employment standards","nda","privacy","payroll","rules","research","library","regulation"],"compliance:ask":["ask","question","chat","assistant","official sources","article","best practices","research"],"compliance:library":["library","guides","best practices","notes","entries","rules","sources","nda","knowledge"],"compliance:items":["open items","regulation updates","suggestions","settings changes","rules to review","decisions","platform changes"],"compliance:research":["what's new","run research","check for new rules","pages we watch","known rules","schedule"],"page:logs":["observability","observe","runs","traces","tracing","events","debug","errors","failures","workflows","monitoring","developer"],"page:history":["history","audit","audit log","audit trail","activity","changes","change log","who changed","undo","roll back","rollback","revert","restore","track changes"],"page:settings":["preferences","configuration","config","options","admin"],"page:developers":["developer","developer portal","api","rest api","integrations","build","sdk","programmatic","automation"],"page:godMode":["god mode","admin","platform","waitlist","sign-ups","signups","approve","workspaces","organizations","spend","ai usage"],"developers:overview":["developer portal","get started","api base url","first request"],"developers:keys":["api key","api keys","keys","tokens","secret","credentials","bearer","rotate key","revoke key"],"developers:webhooks":["webhook","events","callbacks","endpoints","signing secret","deliveries","notifications"],"developers:usage":["analytics","api usage","requests","traffic","error rate","latency","response time","metrics","webhook deliveries"],"developers:requests":["request log","logs","request id","x-request-id","api errors","failed requests","debug"],"developers:connect":["mcp","claude","chatgpt","cursor","ai apps","connect an agent","terminal","cli"],"developers:docs":["documentation","docs","api reference","guides","tutorials","openapi","llms.txt"],"transactions:all":["everything","all expenses","list"],"transactions:needs_you":["review","attention","to do","todo","action needed","missing receipts","questions"],"transactions:working":["in progress","processing","pending","queue","ai working"],"transactions:done":["reviewed","finished","completed","closed","booked"],"transactions:matching":["reconcile","reconciliation","match receipts","receipt matches","pair receipts"],"transactions:stripe":["reconcile","reconciliation","stripe","deposits","payouts","fees"],"transactions:bank":["reconcile","reconciliation","bank records","statement lines","close period","close the books","month end"],"transactions:merchants":["vendors","suppliers","who we paid","payees","spend by merchant","companies","top vendors","slack","profile"],"transactions:trips":["travel","hotel","hotels","stay","hotel hold","holds","map","places","location","business trip","flights","rides"],"transactions:accounts":["bank accounts","cards","credit cards","import","csv","statements","upload statement","wise","rbc"],"transactions:statements":["bank statements","wise statements","monthly statement","statement pdf","originals","statement files","credit card statements"],"inbox:receipts":["invoices","bills","uploads","documents","receipts to review"],"inbox:email":["mail","messages","all mail","company email"],"inbox:quarantine":["spam","blocked","suspicious","held mail","security","phishing"],"inbox:connected":["gmail","google","outlook","microsoft","office 365","connect email","connect inbox","inbox scanning"],"inbox:mine":["my uploads","my receipts","receipts"],"inbox:uploads":["uploads","upload history","files","dropped files","where did my file go","added files","intake"],"ai:overview":["autopilot","jobs","status","run a job","run ai"],"ai:classifiers":["models","thresholds","routing","matching model","classification","certainty","confidence"],"ai:playground":["harness","console","sandbox","test","try"],"ai:memory":["rules","learned rules","merchant rules","notes","knowledge","context"],"ai:agents":["agents","monitor","live","running","runs","activity","what is ai doing","agent status","inbox scanner","matcher"],"ai:connections":["mcp","api","api keys","keys","tokens","developer","integrations","claude","chatgpt","cursor","connect an agent"],"ai:settings":["autopilot settings","receipt minimum","receipt threshold","grace days","automation settings"],"contractors:directory":["all contractors","list","people","contacts","portal access"],"contractors:timesheets":["hours","time","time sheets","approvals","approve hours"],"contractors:history":["past timesheets","all entries","unpaid","paid","owed","mark paid","imported hours","timesheet log"],"contractors:payouts":["payments","pay","pay contractors","wise","transfers","send money","payroll"],"contractors:hours-form":["form","fields","custom fields","timesheet form"],"contractors:activity":["log","history","audit"],"contractors:setup":["contractor setup","more contractor pages"],"contractors:roles":["levels","pay bands","titles"],"contractors:import":["spreadsheet","csv","add several","bulk"],"contractors:insights":["contractor cost","spend","how much"],"contractors:templates":["agreement templates","contracts","documents"],"contractors:tax":["t4a","t4a-nr","slips","1099","w-9","w9","year end","calendar year","tax forms","reporting","cra","irs"],"contractors:email":["notifications","emails sent","delivery","email log"],"contractors:documents":["contractor documents","invoices","contractor invoices","files","records"],"contractors:settings":["reminders","approvers","approvals","pay schedule","cadence","wise settings","payout settings"],"settings:company":["company","business","organization","profile","categories","reminders","invoicing"],"settings:money":["bank","banks","wise","stripe","rbc","connect bank","sync","money"],"settings:email":["email","classifiers","senders","forwarding","routing","mail rules","inbound","email in","receipts"],"settings:developer":["developer","connectors","data sources","notion","google drive"],"settings:ai":["ai keys","api key","openai","typesafe","jev","gemini","google","ai gateway","vercel","byok","bring your own key","z.ai","glm"],"settings:ai-keys":["ai keys","openai key","typesafe key","gemini key","ai gateway key","byok"],"settings:organization":["company","business","legal name","fiscal year","year end","address","logo","business number","profile"],"settings:accountants":["accountant","accountants","bookkeeper","cpa","permissions","share books","invite","access"],"settings:people":["members","team","teammates","users","invite","roles","permissions","access","accountant"],"settings:mail":["email","classifiers","senders","forwarding","routing","mail rules"],"settings:categories":["chart of accounts","coa","expense categories","gifi","accounts"],"settings:connections":["bank","banks","wise","stripe","rbc","connect bank","sync"],"settings:connectors":["notion","integrations","data sources","crm","import data"],"settings:documents":["invoicing","invoice numbering","letterhead","branding","logo","payment methods","templates"],"settings:reminders":["notifications","compliance reminders","emails","alerts","deadlines","due dates"],"settings:receipt-reminders":["missing receipts","receipt chase","cardholders","card receipts"],"settings:deadlines":["filings","payroll","instalments","annual return","t4","t5018","incorporation"],"settings:regulations":["regulation updates","tax rules","law changes","official sources"],"settings:joining":["new people","joins","join notices","notifications"],"settings:senders":["approved senders","blocked senders","allowed senders","vendor emails"],"settings:email-types":["classifiers","email types","routing","guidance","sorting"],"settings:sending":["email domain","custom domain","dns","sending names","from address","test email"],"invoices:all":["all invoices","sent invoices"],"invoices:needs_action":["approve invoices","invoices to send","late payments"],"invoices:open":["unpaid invoices","receivables","accounts receivable","owed"],"invoices:overdue":["late invoices","past due","collections"],"invoices:paid":["paid invoices","collected"],"invoices:draft":["draft invoices","unsent"],"invoices:scheduled":["recurring","subscriptions","schedules","payment plans","automation"],"invoices:uncollectible":["written off","bad debt","uncollectible"],"invoices:void":["cancelled invoices","void","voided"],"invoices:archived":["archived invoices","old invoices"],"invoices:customers":["clients","customers","parties","contacts"],"invoices:vendors":["vendors","suppliers"],"invoices:archived_accounts":["archived customers","archived vendors","former clients"],"documents:all":["envelopes","signatures","sent documents","documents"],"documents:templates":["agreement templates","nda","contract templates"],"documents:contracts":["contractor contracts","contractor agreements","employee contracts","expiring","expired","ending agreements","active agreements","renewals","timeline"],"documents:jobs":["job descriptions","job roles","roles","pay bands","positions"],"checklist:calendar":["dates","important dates","deadlines","schedule","paydays","pay dates"],"reports:stripe":["stripe","fees","revenue","stripe report"],"tax:gst":["gst","hst","sales tax","gst return","hst return","itc","input tax credits"],"tax:corporate":["t2","corporate","income tax","year end","year-end","gifi"],"tax:setup":["business number","bn","gst registration","hst registration","fiscal year","company details","tax setup"],"tax:info":["taxes","tax info","tax information","hst","gst","gst/hst number","gst number","hst number","rt0001","registration date","gst registration date","hst registration date","business number","filing frequency","tax due dates","due dates","tax deadlines","fiscal year-end","year-end date","incorporation","incorporation date","corporation number","tax documents","registrations"],"tax:prep":["year end","year-end","t2","corporate tax","gifi","tax prep","preparation","returns","filing","accountant"],"tax:file-gst":["file gst","file hst","gst/hst return","netfile","my business account","pay gst","pay hst","hst payment","confirmation number","line 101","line 103","line 106","input tax credits","itc","file it yourself"],"tax:shareholders":["shareholders","shareholder register","share register","cap table","shares","share classes","class a","common shares","directors","officers","schedule 50","dividends","t5","who owns"],"tax:file-t2":["t2","file t2","corporate tax return","corporation income tax","balance due","pay corporate tax","schedule 50","schedule 125","schedule 100","gifi","certified software","notice of assessment","file it yourself"],"tax:file-slips":["t4a","t4a slips","t4a-nr","t4a summary","file slips","contractor slips","web forms","box 048","us contractors","w-8ben","file it yourself"],"tax:stripe":["stripe","gross","fees","payouts","charges","refunds","disputes","chargebacks","stripe fees","bank charges","stripe for the year","stripe year-end"],"tax:records":["records","notice of assessment","noa","reassessment","filed returns","t2 return","gst return","cra letters","payment confirmation","slips","t4","t4a","company documents","articles","bylaws","minute book"],"action:intake":["drop","upload","import","receipts","statement","bank statement","csv","bill","invoice","tax document","notice of assessment","noa","t2","gst return","cra","agreement","contract","company document","articles","bylaws","file","files","attach","add files","new"],"action:upload":["upload","receipt","photo","camera","scan","new","add expense","expense"],"action:import":["import","csv","statement","bank statement","upload statement","new"],"action:invoice":["new invoice","bill a customer","invoice","new"],"action:sign":["sign","signature","agreement","contract","nda","esign","e-sign","new"],"action:contractor":["new contractor","hire","onboard","contractor","new"],"action:accountant":["accountant","bookkeeper","cpa","invite","share books"],"action:sendAccountant":["year-end package","package","accountant package","send to accountant","send to my accountant","zip","send everything","everything for the accountant","handoff","share with accountant","statements pack","send books","year end"],"action:members":["invite","teammate","member","user","team"],"action:apiKey":["api key","token","developer","mcp","new key"],"action:inbox":["gmail","outlook","connect gmail","connect outlook","connect inbox","scan email"]};xQQ={chiefOfStaff:"Chief of Staff",developers:"Developers",transactions:"Transactions",inbox:"Inbox",ai:"AI",compliance:"Compliance",tax:"Taxes",people:"People",documents:"Agreements",insights:"Insights",invoices:"Invoices",godMode:"God Mode"};xZA={page:0,view:1,setting:2,action:3}});import{mkdir as fQQ,readFile as hQQ,writeFile as uQQ}from"node:fs/promises";import{join as mQQ}from"node:path";import{createHash as cQQ}from"node:crypto";function rH(A){return A==="access"||A==="destructive"||A==="external"}function pQQ(A,Q){return lQQ.get(A)??(Q?"read":"write")}function dQQ(A){let Q=[];for(let[B,E]of Object.entries(A.paths??{})){let I=/^\/api\/v1\/accounting\/([^/]+)$/.exec(B),D=E.post;if(!I||!D)continue;let J=D["x-read-only"]===!0;Q.push({name:I[1],summary:D.summary??"",readOnly:J,scopes:D["x-required-scopes"]??[],roles:D["x-allowed-roles"]??[],kind:pQQ(I[1],J),inputSchema:D.requestBody?.content?.["application/json"]?.schema??{type:"object"}})}return Q.sort((B,E)=>B.name.localeCompare(E.name))}function jM(A,Q){let B=Q.toLowerCase().split(/\s+/).filter(Boolean);if(!B.length)return[...A];return A.map((I)=>{let D=I.name.toLowerCase(),J=D.split(/[._]/),G=B.every((H)=>D.includes(H)),U=B.every((H)=>D.includes(H)||I.summary.toLowerCase().includes(H)),Y=D.startsWith(B.join("."))||D===B.join("")?4:G&&J.some((H)=>H.startsWith(B[0]))&&D.startsWith(B[0])?3:G?2:U?1:0;return{action:I,score:Y}}).filter((I)=>I.score>0).sort((I,D)=>D.score-I.score||I.action.name.length-D.action.name.length||I.action.name.localeCompare(D.action.name)).map((I)=>I.action)}function RM(A){return!!A?.inputSchema.properties&&"idempotencyKey"in A.inputSchema.properties}function nQQ(A){return mQQ(nG(),`actions-${cQQ("sha256").update(A).digest("hex").slice(0,16)}.json`)}async function M$(A,Q={}){let B=nQQ(A),E=await hQQ(B,"utf8").then((D)=>JSON.parse(D)).catch(()=>null);if(E&&!Q.fresh&&Date.now()-E.fetchedAt<iQQ)return E.actions;let I=Q.fetch??fetch;try{let D=await I(`${A}/api/openapi.json`,{headers:{...p8(),accept:"application/json",...E?.etag?{"if-none-match":E.etag}:{}},redirect:"error"});if(D.status===304&&E)return await uZA(B,{...E,fetchedAt:Date.now()}),E.actions;if(!D.ok)throw Error(`HTTP ${D.status}`);let J=dQQ(await D.json());return await uZA(B,{fetchedAt:Date.now(),etag:D.headers.get("etag"),actions:J}),J}catch(D){if(E)return E.actions;throw Error(`Couldn't load Oatmilk's list of actions: ${D instanceof Error?D.message:String(D)}`)}}async function uZA(A,Q){await fQQ(nG(),{recursive:!0}).catch(()=>{return}),await uQQ(A,JSON.stringify(Q)).catch(()=>{return})}var lQQ,iQQ=86400000;var gM=W(()=>{$h();AJ();D6();lQQ=new Map(Object.values(xH).map(([A,Q])=>[A,Q]))});function f0({color:A=L.accent,label:Q}){let{frame:B}=x1({interval:80});return d(f,{color:A,children:[j8[B%j8.length],Q?d(f,{color:L.muted,children:[" ",Q]}):null]})}var vD=W(async()=>{bB();HQ();await dB()});function mZA({width:A,height:Q,onClose:B,onUpload:E}){let I=FB(),D=XG(),[J,G]=qE.useState({value:"",cursor:0}),[U,Y]=qE.useState(0),[H,X]=qE.useState(null),[N,z]=qE.useState([]),F=I.role==="admin"||I.role==="finance",V=qE.useMemo(()=>yZA(I.role,!1,I.identity.workspaceKind),[I.role,I.identity.workspaceKind]);qE.useEffect(()=>{M$(I.session.host).then(z,()=>{return})},[I.session.host]);let O=qE.useRef(0),j=J.value.trim(),b=qE.useMemo(()=>H?.query===j?H.items:[],[H,j]),x=j.length>=2&&H?.query!==j;qE.useEffect(()=>{O.current+=1;let CA=O.current;if(j.length<2)return;let GA=setTimeout(()=>{let iA=(IQ)=>()=>{B(),I.navigate(IQ,{focus:"main"})},jA=[I.api.call("entries.list",{search:j,limit:6},{readOnly:!0}).then((IQ)=>IQ.map((_A)=>({key:`entry:${_A.id}`,group:"Transactions",label:_A.merchant??"Transaction",detail:`${aQ(_A.amount_minor,_A.currency)} · ${oQ(_A.date)}`,run:iA(`/finance/transactions?entry=${_A.id}`)})))];if(F)jA.push(I.api.call("mail.list",{search:j,limit:4},{readOnly:!0}).then((IQ)=>IQ.items.map((_A)=>({key:`mail:${_A.id}`,group:"Email",label:_A.subject??"(no subject)",detail:`${_A.sender_email??""} · ${oQ(_A.received_at)}`,run:iA(`/inbox?view=email&mail=${_A.id}`)}))),I.api.call("invoices.list",{search:j,limit:4,offset:0},{readOnly:!0}).then((IQ)=>IQ.items.map((_A)=>({key:`invoice:${_A.id}`,group:"Invoices",label:`${_A.number??"Draft"} · ${_A.party_name??""}`,detail:aQ(_A.total_minor,_A.currency),run:iA(`/finance/invoices?invoice=${_A.id}`)}))),I.api.call("contractors.list",{query:j,limit:4,offset:0},{readOnly:!0}).then((IQ)=>IQ.items.map((_A)=>({key:`contractor:${_A.id}`,group:"Contractors",label:_A.display_name,detail:_A.email??"",run:iA(`/people/contractors?contractor=${_A.id}`)}))));Promise.allSettled(jA).then((IQ)=>{if(CA!==O.current)return;X({query:j,items:IQ.flatMap((_A)=>_A.status==="fulfilled"?_A.value:[])})})},220);return()=>clearTimeout(GA)},[j,I.api,I.navigate,F,B,I]);let v=qE.useMemo(()=>{let CA=(uA)=>({key:uA.id,group:uA.kind==="action"?"Do":"Go to",label:uA.label,detail:uA.parent,run:()=>{if(B(),uA.run==="upload")E();else if(uA.run)I.navigate("/inbox?view=uploads",{focus:"main"});else if(uA.href)I.navigate(uA.href,{focus:"main"})}}),GA=fZA(V,j,j?8:40),iA=j?GA.filter((uA)=>WM(uA,j)>=50).map(CA):GA.map(CA),jA=j?GA.filter((uA)=>WM(uA,j)<50).slice(0,3).map(CA):[],IQ=j?[{key:"ask",group:"Ask AI",label:`Ask Oatmilk: "${j}"`,run:()=>{B(),I.ask(j)}}]:[],_A=j.toLowerCase().split(/\s+/).filter(Boolean),RB=j?N.filter((uA)=>_A.every((sA)=>uA.name.toLowerCase().includes(sA)||uA.summary.toLowerCase().includes(sA))).slice(0,5).map((uA)=>({key:`action:${uA.name}`,group:"Run an action",label:uA.name,detail:uA.summary.slice(0,60),run:()=>{B(),I.navigate(`${D1}?action=${encodeURIComponent(uA.name)}`,{focus:"main"})}})):[],YA=[{key:"cli:new-chat",group:"Ask AI",label:"New chat",run:()=>{B(),I.chat.start(null),I.setChatVisible(!0),I.setFocus("composer")}},{key:"cli:chats",group:"Ask AI",label:"Recent chats",run:()=>{I.setOverlay("chats")}},{key:"cli:org",group:"Do",label:"Switch workspace",run:()=>{I.setOverlay("orgs")}},{key:"cli:actions",group:"Do",label:"Run an action",run:()=>{B(),I.navigate(D1,{focus:"main"})}},{key:"cli:themes",group:"Theme",label:"Themes…",detail:D.shownName,run:()=>{I.setOverlay("theme")}}].filter((uA)=>!j||_A.every((sA)=>uA.label.toLowerCase().includes(sA))),yA=["theme","themes","appearance","color","colors","colour","mode","dark","light","night","day"],YQ=(uA)=>_A.every((sA)=>uA.toLowerCase().includes(sA)),yQ=j?KG().filter((uA)=>_A.every((sA)=>uA.name.toLowerCase().includes(sA)||yA.some((qQ)=>qQ.startsWith(sA)))).sort((uA,sA)=>Number(YQ(sA.name))-Number(YQ(uA.name))).slice(0,6).map((uA)=>({key:`theme:${uA.id}`,group:"Theme",label:uA.name,detail:uA.id===D.choice?"current":void 0,run:()=>{B(),D.choose(uA.id),I.toast(`Theme: ${uA.name}`,"success")}})):[],zQ=[...iA,...YA,...yQ,...b.filter((uA)=>aQQ.includes(uA.group)),...RB,...jA];return j?[...zQ,...IQ]:zQ},[V,j,b,N,I,B,E,D]),[w,k]=qE.useState(j);if(w!==j)k(j),Y(0);iQ((CA,GA)=>{if(GA.escape){B();return}if(GA.upArrow){Y((jA)=>Math.max(0,jA-1));return}if(GA.downArrow||GA.tab){Y((jA)=>Math.min(v.length-1,jA+1));return}if(GA.return){v[U]?.run();return}let iA=BI(J,CA,GA,200);if(iA.type==="edit")G(iA.state)}),z8((CA)=>G((GA)=>j4(GA,CA.replace(/\n/g," "),200)));let h=Math.min(90,A-4),t=Math.max(5,Math.min(Q-8,18)),i=Math.max(0,Math.min(U-t+3,v.length-t)),UA=v.slice(i,i+t);return R(e,{position:"absolute",top:0,left:0,width:A,height:Q,justifyContent:"center",alignItems:"flex-start",paddingTop:1,children:d(e,{flexDirection:"column",width:h,borderStyle:"single",borderColor:L.focus,paddingX:1,backgroundColor:L.panel,children:[d(e,{justifyContent:"space-between",children:[R(p0,{state:J,width:h-8,placeholder:"Jump to a page, find a record, run an action, or ask…",prefix:[{text:`${hA.prompt} `,color:L.accent,bold:!0}]}),x?R(f0,{}):null]}),R(f,{color:L.border,children:"─".repeat(h-4)}),UA.map((CA,GA)=>{let iA=i+GA,jA=iA===U,IQ=iA===0||v[iA-1].group!==CA.group;return d(e,{flexDirection:"column",children:[IQ?R(f,{color:L.faint,bold:!0,children:CA.group.toUpperCase()}):null,d(e,{justifyContent:"space-between",children:[d(f,{color:jA?L.focus:L.text,bold:jA,wrap:"truncate-end",children:[jA?hA.pointer:" "," ",CA.label]}),CA.detail?d(f,{color:L.faint,wrap:"truncate-end",children:[" ",CA.detail]}):null]})]},CA.key)}),!v.length?R(f,{color:L.muted,children:x?"Searching…":"Nothing matches. Press ⏎ to ask Oatmilk."}):null,R(f,{color:L.faint,children:"↑↓ choose · ⏎ open · Esc close"})]})})}var qE,aQQ;var cZA=W(async()=>{hZA();gM();d1();RD();qG();NG();bB();BE();bB();HQ();await $0([dB(),gD(),vD()]);qE=pA(JQ(),1),aQQ=["Transactions","Email","Invoices","Contractors"]});function oQQ(A,Q,B,E={},I="company"){let D=Q.startsWith("/cli/")?null:sXA(uU(Q)),J=[];for(let U of MZA(A,!1,I)){J.push({kind:"area",label:U.label.toUpperCase()});for(let Y of U.destinations){let H=Y.id===D;if(J.push({kind:"page",label:Y.label,href:Y.href,active:H,count:E[Y.id]}),!H)continue;for(let X of Y.children){let N=new URL(X.href,"https://x.invalid"),z=N.pathname===Q&&[...N.searchParams].every(([F,V])=>B.get(F)===V);J.push({kind:"child",label:X.label,href:X.href,active:z})}}}let G=q$(A,!1,I).find((U)=>U.id==="settings");if(J.push({kind:"area",label:"MORE"}),G)J.push({kind:"page",label:"Settings",href:G.href,active:D==="settings"});return J.push({kind:"page",label:"Run an action",href:D1,active:Q===D1}),J}function lZA({height:A,counts:Q}){let{role:B,route:E,navigate:I,focus:D,layout:J,identity:G}=FB(),U=sH.useMemo(()=>oQQ(B,E.path,E.params,Q,G.workspaceKind),[B,E.path,E.params,Q,G.workspaceKind]),Y=U.map((b,x)=>b.href?x:-1).filter((b)=>b>=0),H=U.findIndex((b)=>b.active&&b.kind==="child")>=0?U.findIndex((b)=>b.active&&b.kind==="child"):U.findIndex((b)=>b.active),[X,N]=sH.useState(Math.max(0,H)),z=D==="sidebar",[F,V]=sH.useState({focused:z,activeIndex:H});if(F.focused!==z||F.activeIndex!==H){if(V({focused:z,activeIndex:H}),!z&&H>=0)N(H)}iQ((b,x)=>{let v=Math.max(0,Y.indexOf(X)),w=/^(j+|k+)$/.test(b)?b.length:1;if(x.upArrow||/^k+$/.test(b))N(Y[Math.max(0,v-w)]??X);else if(x.downArrow||/^j+$/.test(b))N(Y[Math.min(Y.length-1,v+w)]??X);else if(x.home||b==="g")N(Y[0]);else if(x.end||b==="G")N(Y.at(-1));else if(x.return||x.rightArrow||b==="l"){let k=U[X];if(k?.href)I(k.href,{focus:"main"})}},{isActive:z});let O=J.sidebarWidth,j=Math.max(0,Math.min(X-Math.floor(A/2),U.length-A));return R(e,{flexDirection:"column",width:O,height:A,paddingLeft:1,paddingRight:1,borderStyle:"single",borderTop:!1,borderBottom:!1,borderLeft:!1,borderColor:z?L.focus:L.border,children:U.slice(j,j+A).map((b,x)=>{let v=j+x,w=z&&v===X;if(b.kind==="area")return d(f,{color:L.faint,bold:!0,children:[v===0?"":"",b.label]},v);let k=b.kind==="child"?" ":"",h=w?hA.pointer:b.active?"•":" ",t=w?L.focus:b.active?L.text:b.kind==="child"?L.muted:L.text;return d(e,{justifyContent:"space-between",children:[d(f,{color:t,bold:b.active&&b.kind==="page",wrap:"truncate-end",children:[k,h," ",b.label]}),b.count?R(f,{color:L.highlight,children:b.count>99?"99+":b.count}):null]},v)})})}var sH;var pZA=W(async()=>{mU();qG();BE();bB();HQ();await dB();sH=pA(JQ(),1)});function iZA(A){if(A>=dZA[0].length+4)return dZA;if(A>=pU[0].length+4)return pU;return["◆ oatmilk"]}var dZA,pU;var ah=W(()=>{dZA=[" ██████ █████ ████████ ███ ███ ██ ██ ██ ██","██ ██ ██ ██ ██ ████ ████ ██ ██ ██ ██ ","██ ██ ███████ ██ ██ ████ ██ ██ ██ █████ ","██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ "," ██████ ██ ██ ██ ██ ██ ██ ███████ ██ ██"],pU=["▄▀▀▄ ▄▀▀▄ ▀█▀ █▄▀▄█ █ █ █▄▀","▀▄▄▀ █▀▀█ █ █ ▀ █ █ █▄▄ █ █"]});function oh({text:A,shine:Q,width:B}){let E=[...A],I=[];return E.forEach((D,J)=>{let G=e2A(ZM,B>1?J/(B-1):0),U=Q===void 0?1/0:Math.abs(J-Q),Y=U<6?AXA(G,0.55*(1-U/6)):G,H=I.at(-1);if(H&&H.color===Y)H.text+=D;else I.push({text:D,color:Y})}),R(f,{children:I.map((D,J)=>R(f,{color:D.color,children:D.text},J))})}function rh({columns:A,animate:Q=!0}){let B=iZA(A),E=Math.max(...B.map((J)=>[...J].length)),{frame:I}=x1({interval:40,isActive:Q}),D=Q?I*2%(E+40)-10:void 0;return R(e,{flexDirection:"column",children:B.map((J,G)=>R(oh,{text:J,width:E,shine:D===void 0?void 0:D-G*2},G))})}function i1({columns:A,rows:Q,status:B,working:E=!0,children:I}){return d(e,{width:A,height:Q,flexDirection:"column",alignItems:"center",justifyContent:"center",children:[R(rh,{columns:A}),d(e,{marginTop:1,gap:2,children:[R(f,{color:L.muted,children:"Your company's books, in your terminal"}),d(f,{color:L.faint,children:["v",DI]})]}),R(e,{marginTop:1,minHeight:1,children:E?R(f0,{label:B}):R(f,{color:L.muted,children:B})}),I?R(e,{marginTop:1,flexDirection:"column",alignItems:"center",children:I}):null]})}var tH=W(async()=>{bB();ah();l8();HQ();await $0([dB(),vD()])});function nZA({hints:A,toast:Q}){let{focus:B,chat:E,layout:I}=FB(),D=HG(E),J=B==="main"?A:rQQ[B]??A,G=Q?.tone==="danger"?L.danger:Q?.tone==="warning"?L.warning:Q?.tone==="success"?L.success:L.info;return d(e,{width:I.columns,height:1,overflow:"hidden",paddingX:1,justifyContent:"space-between",children:[Q?d(f,{color:G,wrap:"truncate-end",children:[Q.tone==="danger"?"✗ ":Q.tone==="success"?"✓ ":"• ",Q.message]}):R(f,{color:L.faint,wrap:"truncate-end",children:J}),D.busy?R(e,{flexShrink:0,children:R(f0,{label:B==="composer"?"Ask AI is working · Esc to stop":"Ask AI is working"})}):null]})}var rQQ;var aZA=W(async()=>{BE();pH();bB();HQ();await $0([dB(),vD()]);rQQ={sidebar:"↑↓ move · ⏎ open · Tab next · / ask · q quit",composer:"⏎ send · ⌥⏎ new line · ↑ history · / commands · Esc browse",overlay:"Esc close"}});function rZA({host:A,columns:Q,rows:B,onSignedIn:E,onQuit:I,password:D=!1}){let J=D?[sQQ,...oZA]:oZA,[G,U]=MG.useState({kind:"menu"}),[Y,H]=MG.useState(0),X=MG.useRef(null),N=MG.useRef(null);MG.useEffect(()=>()=>X.current?.abort(),[]);let z=async(O)=>{U({kind:"saving"}),await zB(A,(b)=>({...b,credential:O}));let j=await sQ();j.defaultHost=A,await FI(j),E()},F=(O)=>{if(O==="quit"){I();return}if(O==="key"){U({kind:"key",state:{value:"",cursor:0}});return}if(O==="password"){sQ().then((x)=>{let v=x.hosts[A]?.localAccount?.email??"";U({kind:"password",field:"email",email:v,state:{value:v,cursor:v.length}})});return}X.current?.abort();let j=new AbortController;X.current=j;let b=(x)=>{if(!j.signal.aborted)U({kind:"error",message:CQ(x)})};if(O==="browser"){U({kind:"browser",url:null,opened:!1}),W6({host:A,signal:j.signal,onAuthorizationUrl:async(x)=>{let v=await PE(x);U({kind:"browser",url:x,opened:v})}}).then(z,b);return}U({kind:"paste",url:null,state:{value:"",cursor:0}}),zZ({host:A,onAuthorizationUrl:(x)=>{if(!j.signal.aborted)U({kind:"paste",url:x,state:{value:"",cursor:0}})},readCode:(x)=>new Promise((v)=>{if(N.current=v,x&&!j.signal.aborted)U((w)=>w.kind==="paste"?{...w,state:{value:"",cursor:0},problem:x}:w)})}).then((x)=>{if(!j.signal.aborted)return z(x)},b)};if(iQ((O,j)=>{if(G.kind==="menu"){let b=/^(j+|k+)$/.test(O)?O.length:1;if(j.upArrow||/^k+$/.test(O))H((x)=>Math.max(0,x-b));else if(j.downArrow||/^j+$/.test(O))H((x)=>Math.min(J.length-1,x+b));else if(/^[1-9]$/.test(O)&&Number(O)<=J.length)F(J[Number(O)-1].id);else if(j.return)F(J[Y].id);else if(O==="q"||j.escape)I();return}if(G.kind==="password"){if(j.escape){U({kind:"menu"});return}let b=BI(G.state,O,j,300);if(b.type==="edit"){U({...G,state:b.state});return}if(b.type!=="submit")return;let x=G.state.value.trim();if(G.field==="email"){if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x)){U({...G,error:"Enter the email you signed up with."});return}U({kind:"password",field:"password",email:x.toLowerCase(),state:{value:"",cursor:0}});return}if(!G.state.value)return;let v=G.email,w=G.state.value;U({kind:"saving"}),s8({host:A,email:v,password:w}).then((k)=>z(k),(k)=>U({kind:"password",field:"password",email:v,state:{value:"",cursor:0},error:CQ(k)}));return}if(G.kind==="paste"){if(j.escape){X.current?.abort(),N.current=null,U({kind:"menu"});return}let b=BI(G.state,O,j,4000);if(b.type==="submit"&&G.state.value.trim()&&N.current){let x=N.current;N.current=null,U({...G,problem:void 0}),x(G.state.value)}else if(b.type==="edit")U({...G,state:b.state});return}if(G.kind==="key"){if(j.escape){U({kind:"menu"});return}let b=BI(G.state,O,j,200);if(b.type==="submit"){let x=G.state.value.trim();if(!n5(x)){U({...G,error:"That isn't an Oatmilk API key. Keys start with oat_."});return}z({type:"api_key",apiKey:x}).catch((v)=>U({kind:"error",message:CQ(v)}))}else if(b.type==="edit")U({kind:"key",state:b.state});return}if(j.escape||G.kind==="error"&&j.return)X.current?.abort(),U({kind:"menu"})}),G.kind==="menu")return d(i1,{columns:Q,rows:B,status:`Sign in to ${TI(A)}`,working:!1,children:[R(e,{flexDirection:"column",borderStyle:"single",borderColor:L.border,paddingX:2,paddingY:0,width:Math.min(44,Q-4),children:J.map((O,j)=>d(f,{color:j===Y?L.focus:L.text,bold:j===Y,wrap:"truncate-end",children:[j===Y?`${hA.pointer} `:" ",j+1," ",O.label]},O.id))}),R(f,{color:L.muted,children:J[Y].detail||" "}),R(f,{color:L.faint,children:"↑↓ choose · ⏎ continue · q quit"})]});let V=Math.min(Q-4,100);if(G.kind==="browser")return R(i1,{columns:Q,rows:B,status:G.url?"Waiting for you to approve in the browser…":"Opening your browser…",children:G.url?d(e,{flexDirection:"column",alignItems:"center",width:V,children:[R(f,{color:L.muted,children:G.opened?"If the page didn't open, visit:":"Open this address to sign in:"}),R(f,{color:L.info,wrap:"wrap",children:G.url}),R(f,{color:L.faint,children:"Esc to go back"})]}):null});if(G.kind==="paste")return R(i1,{columns:Q,rows:B,status:G.url?"Sign in on any device":"Getting a sign-in link…",working:!G.url,children:G.url?d(e,{flexDirection:"column",alignItems:"center",width:V,children:[R(f,{color:L.muted,children:"Open this address on any device, approve, and copy the code Oatmilk shows:"}),R(e,{marginY:1,children:R(f,{color:L.info,wrap:"wrap",children:G.url})}),R(e,{borderStyle:"single",borderColor:L.focus,paddingX:1,width:Math.min(70,Q-4),children:R(p0,{state:G.state,width:Math.min(66,Q-8),placeholder:"Paste the code here"})}),G.problem?R(f,{color:L.danger,wrap:"wrap",children:G.problem}):R(f,{color:L.faint,children:"⏎ sign in · Esc back"})]}):null});if(G.kind==="key")return d(i1,{columns:Q,rows:B,status:"Paste an API key from Settings › Developer",working:!1,children:[R(e,{borderStyle:"single",borderColor:L.focus,paddingX:1,width:Math.min(70,Q-4),children:R(p0,{state:G.state,width:Math.min(66,Q-8),placeholder:"oat_…",mask:!0})}),G.error?R(f,{color:L.danger,children:G.error}):R(f,{color:L.faint,children:"⏎ sign in · Esc back"})]});if(G.kind==="password")return d(i1,{columns:Q,rows:B,status:G.field==="email"?"Your email":`Password for ${G.email}`,working:!1,children:[R(e,{borderStyle:"single",borderColor:L.focus,paddingX:1,width:Math.min(70,Q-4),children:R(p0,{state:G.state,width:Math.min(66,Q-8),placeholder:G.field==="email"?"you@company.com":"password",mask:G.field==="password"})}),G.error?R(f,{color:L.danger,wrap:"wrap",children:G.error}):d(f,{color:L.faint,children:["⏎ ",G.field==="email"?"next":"sign in"," · Esc back"]})]});if(G.kind==="saving")return R(i1,{columns:Q,rows:B,status:"Signing you in…"});return d(i1,{columns:Q,rows:B,status:"The sign-in didn't finish",working:!1,children:[R(e,{width:Math.min(80,Q-4),justifyContent:"center",children:R(f,{color:L.danger,wrap:"wrap",children:G.message})}),R(f,{color:L.faint,children:"⏎ try again"})]})}var MG,oZA,sQQ;var sZA=W(async()=>{Q5();IC();UJ();wQ();F1();oI();S0();RD();bB();HQ();await $0([dB(),gD(),tH()]);MG=pA(JQ(),1),oZA=[{id:"browser",label:"Sign in with your browser",detail:"Recommended: approve in the browser, then come back here"},{id:"device",label:"Sign in on another device",detail:"For SSH and machines without a browser: paste back the code Oatmilk shows"},{id:"key",label:"Paste an API key",detail:"Make one in Settings › Developer"},{id:"quit",label:"Quit",detail:""}],sQQ={id:"password",label:"Sign in with your password",detail:"Your account on this computer's Oatmilk; forgot it? oatmilk local password --reset"}});function tQQ(A,Q={}){let B=new URLSearchParams({organization:A});if(Q.tab)B.set("tab",Q.tab);if(Q.periodId)B.set("period",Q.periodId);else if(Q.date&&IN(Q.date))B.set("date",Q.date);if(Q.agreementId)B.set("agreement",Q.agreementId);if(Q.step)B.set("step",Q.step);if(Q.welcome)B.set("welcome","1");return`/contractor?${B}`}function eH(A,Q,B={}){return`${A}${tQQ(Q,B)}`}var sh=W(()=>{nP()});async function QBQ(A,Q,B){let E=await EB({host:A,organizationId:Q.organizationId});return{session:E,api:new k0(E,void 0,"contractor"),employer:Q,employers:B}}function tZA({host:A,employers:Q,columns:B,rows:E,onQuit:I}){let[D,J]=_I.useState(Q.length===1?Q[0]:null),[G,U]=_I.useState(null),[Y,H]=_I.useState(null),[X,N]=_I.useState(void 0),[z,F]=_I.useState(null),[V,O]=_I.useState(Q.length>1?{kind:"companies",index:0}:{kind:"view"}),[j,b]=_I.useState(TM),[x,v]=_I.useState(null);_I.useEffect(()=>{if(D||Q.length<=1)return;G4(A).then((YA)=>{let yA=Q.find((YQ)=>YQ.organizationId===YA.contractorOrganizationId);if(yA)J(yA),O({kind:"view"})})},[D,Q,A]),_I.useEffect(()=>{if(!D)return;let YA=!1;return QBQ(A,D,Q).then((yA)=>{if(!YA)U(yA)},(yA)=>{if(!YA)F(CQ(yA))}),()=>{YA=!0}},[A,D,Q]);let w=_I.useCallback(async(YA=X)=>{if(!G)return;try{H(await MJ(G,{periodId:YA})),F(null)}catch(yA){F(CQ(yA))}},[G,X]);_I.useEffect(()=>{if(!G)return;let YA=!1;return MJ(G,{periodId:X}).then((yA)=>{if(!YA)H(yA),F(null)},(yA)=>{if(!YA)F(CQ(yA))}),()=>{YA=!0}},[G,X]),_I.useEffect(()=>{if(!x)return;let YA=setTimeout(()=>v(null),x.tone==="danger"?7000:4000);return()=>clearTimeout(YA)},[x]);let k=_I.useMemo(()=>Y?zC(Y):[],[Y]),h=Y?.period.status==="paid"||Y?.period.status==="skipped",t=async(YA,yA,YQ,yQ=!1)=>{if(!G)return;O({kind:"log",step:2,minutes:yA,description:YQ,saving:!0});try{await a5(G,{date:YA,minutes:yA,description:YQ,confirmDuplicate:yQ}),O({kind:"view"}),b(TM),v({text:`${hA.done} Logged ${xE(yA)} on ${_J(YA)}`,tone:"success"}),await w()}catch(zQ){if(zQ instanceof mQ&&zQ.code==="DUPLICATE_ENTRY"&&!yQ){O({kind:"log",step:2,minutes:yA,description:YQ,duplicate:{date:YA}});return}O({kind:"log",step:2,minutes:yA,description:YQ,error:CQ(zQ)})}},i=async(YA)=>{if(!G||!Y)return;O({kind:"confirm",action:YA,busy:!0});try{if(YA==="send"){let yA=await JN(G,Y.period);H(yA.timesheet),v({text:`${hA.done} Sent ${yA.submitted.length} ${yA.submitted.length===1?"entry":"entries"} to ${G.employer.name} for review`,tone:"success"})}else await GN(G,Y.period),v({text:`${hA.done} ${G.employer.name} knows you had no hours this period`,tone:"success"}),await w()}catch(yA){v({text:yA instanceof mQ&&yA.code==="DETAILS_REQUIRED"?`${yA.message} Press o to add them in the portal.`:CQ(yA),tone:"danger"})}O({kind:"view"})},UA=()=>{if(!G)return;let YA=eH(G.session.host,G.employer.organizationId,{tab:"hours",...Y?.period.id?{periodId:Y.period.id}:{}});PE(YA).then((yA)=>v({text:yA?"Opened your portal in the browser":YA,tone:"info"}))},CA=(YA)=>{if(!Y?.periods.length)return;let yA=[...Y.periods].sort((zQ,uA)=>zQ.periodStart.localeCompare(uA.periodStart)),YQ=yA.findIndex((zQ)=>zQ.periodStart===Y.period.periodStart),yQ=yA[YQ+YA];if(!yQ?.id)return;N(yQ.id),H(null)};iQ((YA,yA)=>{if(yA.ctrl&&YA==="c"){I();return}if(V.kind==="companies"){if(yA.upArrow||YA==="k")O({kind:"companies",index:Math.max(0,V.index-1)});else if(yA.downArrow||YA==="j")O({kind:"companies",index:Math.min(Q.length-1,V.index+1)});else if(yA.return){let YQ=Q[V.index];if(YQ.organizationId!==D?.organizationId)U(null),H(null);J(YQ),N(void 0),O({kind:"view"}),DN(A,YQ)}else if(yA.escape&&D)O({kind:"view"});else if(YA==="q")I();return}if(V.kind==="confirm"){if(V.busy)return;if(YA==="y"||yA.return)i(V.action);else if(YA==="n"||yA.escape)O({kind:"view"});return}if(V.kind==="log"){if(V.saving)return;if(V.duplicate){if(YA==="y")t(V.duplicate.date,V.minutes,V.description,!0);else if(YA==="n"||yA.escape)O({kind:"view"});return}if(yA.escape){if(V.step===0){O({kind:"view"}),b(TM);return}let yQ=V.step-1;b(th(yQ===0?xE(V.minutes??0):V.description??"")),O({...V,step:yQ,error:void 0});return}let YQ=BI(j,YA,yA,2000);if(YQ.type==="edit"){b(YQ.state);return}if(YQ.type!=="submit")return;try{if(V.step===0){let yQ=CN(j.value);O({kind:"log",step:1,minutes:yQ}),b(th(V.description??""))}else if(V.step===1){let yQ=j.value.trim();if(!yQ){O({...V,error:"Say what you did."});return}O({kind:"log",step:2,minutes:V.minutes,description:yQ}),b(th("today"))}else t(VJ(j.value||"today"),V.minutes,V.description)}catch(yQ){O({...V,error:CQ(yQ)})}return}if(YA==="q")I();else if(!Y)return;else if((YA==="a"||yA.return)&&!h)b(TM),O({kind:"log",step:0});else if(YA==="s"&&k.length&&!h)O({kind:"confirm",action:"send"});else if(YA==="n"&&!Y.entries.length&&!Y.period.noHoursReportedAt&&Y.period.id&&!h)O({kind:"confirm",action:"none"});else if(YA==="[")CA(-1);else if(YA==="]")CA(1);else if(YA==="c"&&Q.length>1)O({kind:"companies",index:Math.max(0,Q.findIndex((YQ)=>YQ.organizationId===D?.organizationId))});else if(YA==="o")UA();else if(YA==="r")w()});let GA=Math.max(30,Math.min(B-4,100)),iA=d(e,{width:GA,marginBottom:1,children:[d(f,{bold:!0,color:L.accent,children:[hA.brand," oatmilk"]}),R(f,{color:L.muted,children:` ${D?.name??"Your hours"} ${hA.dot} contractor`})]}),jA=(YA,yA)=>d(e,{width:B,height:E,flexDirection:"column",alignItems:"center",paddingTop:1,children:[iA,R(e,{flexDirection:"column",width:GA,flexGrow:1,children:YA}),d(e,{width:GA,flexDirection:"column",children:[x?R(f,{color:x.tone==="success"?L.success:x.tone==="danger"?L.danger:L.info,wrap:"wrap",children:x.text}):null,R(f,{color:L.faint,wrap:"truncate-end",children:yA})]})]});if(V.kind==="companies")return jA(d(PB,{children:[R(f,{bold:!0,children:"Which company are these hours for?"}),R(e,{flexDirection:"column",marginTop:1,children:Q.map((YA,yA)=>d(f,{color:yA===V.index?L.focus:L.text,bold:yA===V.index,children:[yA===V.index?`${hA.pointer} `:" ",YA.name]},YA.organizationId))})]}),`↑↓ choose · ⏎ open${D?" · Esc back":""} · q quit`);if(z&&!Y)return jA(R(f,{color:L.danger,wrap:"wrap",children:z}),"r try again · o portal · q quit");if(!Y)return jA(d(PB,{children:[R(f,{color:L.muted,children:"Your hours"}),R(e,{marginTop:1,children:R(zE,{rows:4,width:GA,columns:[12,7,Math.max(10,GA-44),14],label:"Opening your hours"})})]}),"q quit");if(V.kind==="log"){let YA=V.duplicate?`You already logged "${V.description}" on ${_J(V.duplicate.date)}. Keep both?`:eQQ[V.step];return jA(d(PB,{children:[R(f,{color:L.muted,children:`${V.step+1}/3`}),R(f,{bold:!0,wrap:"wrap",children:YA}),V.duplicate?null:R(e,{marginTop:1,borderStyle:"single",borderColor:L.focus,paddingX:1,children:R(p0,{state:j,width:GA-4,placeholder:ABQ[V.step]})}),V.saving?R(f0,{label:"Saving…"}):V.error?R(f,{color:L.danger,wrap:"wrap",children:V.error}):null]}),V.duplicate?"y keep both · n don't":V.step===2?"⏎ log it · Esc back":"⏎ next · Esc back")}if(V.kind==="confirm"){let YA=V.action==="send"?`Send ${k.length} ${k.length===1?"entry":"entries"} (${xE(qC(k))}) to ${D?.name} for review?`:`Tell ${D?.name} you had no hours ${C9(Y.period).split(` ${hA.dot} `)[0]}?`;return jA(d(PB,{children:[R(f,{bold:!0,wrap:"wrap",children:YA}),V.busy?R(e,{marginTop:1,children:R(f0,{label:"Sending…"})}):null]}),"y yes · n no")}let IQ=[...Y.entries].sort((YA,yA)=>YA.date.localeCompare(yA.date)),_A=Math.max(10,GA-44),RB=h?null:k.length?`s Send ${k.length===1?"it":`these ${k.length}`} for review`:"a Log time";return jA(d(PB,{children:[R(f,{bold:!0,wrap:"truncate-end",children:C9(Y.period)}),d(e,{flexDirection:"column",marginTop:1,children:[IQ.length?IQ.map((YA)=>d(f,{wrap:"truncate-end",children:[uI(_J(YA.date),12)," ",uI(xE(YA.minutes),7,"right")," ",uI(YA.description,_A)," ",R(f,{color:YA.status==="rejected"?L.danger:YA.status==="approved"?L.success:YA.status==="draft"?L.warning:L.muted,children:o5(YA)})]},YA.id)):R(f,{color:L.muted,children:Y.period.noHoursReportedAt?"You said you had no hours this period.":"No hours logged yet."}),IQ.length?R(f,{color:L.muted,children:`${xE(qC(IQ))} in all${k.length?` ${hA.dot} ${k.length} not sent yet`:""}`}):null]}),RB?R(e,{marginTop:1,children:d(f,{bold:!0,color:L.focus,children:[hA.pointer," ",RB]})}):null,k.some((YA)=>YA.missing?.length)?R(f,{color:L.warning,wrap:"wrap",children:"Some entries need more details in the portal (press o)."}):null]}),["a log time",k.length&&!h?"s send":null,!Y.entries.length&&Y.period.id&&!h?"n no hours":null,"[ ] period",Q.length>1?"c company":null,"o portal","q quit"].filter(Boolean).join(` ${hA.dot} `))}var _I,eQQ,ABQ,TM,th=(A)=>({value:A,cursor:A.length});var eZA=W(async()=>{sh();SE();UJ();$9();wQ();d1();oI();S0();RD();bB();HQ();await $0([dB(),gD(),FG(),vD()]);_I=pA(JQ(),1),eQQ=["How long did you work?","What did you do?","Which day?"],ABQ=["2h, 1h30m or 1:30","Design review","today, yesterday, mon or 2026-10-06"],TM={value:"",cursor:0}});function PM({percent:A,label:Q=!0}){let B=Math.max(0,Math.min(100,Math.round(A)));return d(f,{children:[d(f,{bold:!0,color:B>=75?L.success:B>0?L.text:L.muted,children:[B,"% local"]}),Q?R(f,{color:L.muted,children:` · ${LK(B)}`}):null]})}var eh=W(async()=>{Z4();bB();HQ();await dB()});function IBQ(A,Q,B,E){if(!A||A==="cloud"||A==="remote"||A==="more")return[];let I=A==="custom"?["parts"]:[];if(E)I.push("servers","models");for(let D=0;D<B;D+=1)I.push(`cloud:${D}`);if(Q.account==="local")for(let D=0;D<B2.length;D+=1)I.push(`account:${D}`);return I.push("review"),I}function EBQ(A){if(A.kind==="server-url")return"servers";if(A.kind==="cloud"||A.kind==="account")return`${A.kind}:${A.index}`;return A.kind}function DBQ(A,Q){let B=A.indexOf(Q);return B<0?null:{current:B+1,total:A.length}}function A3A(A,Q){if(Q==="chat")return A.chat;if(Q==="vision")return A.vision??A.chat;if(Q==="classifier")return A.classifier??A.chat;return A.embedding}function JBQ(A,Q,B,E){if(Q==="chat")return{...A,chat:B??A.chat};if(Q==="vision")return{...A,vision:B&&B!==A.chat?B:void 0};if(Q==="classifier")return{...A,classifier:B&&B!==A.chat?B:void 0,classifierApi:B&&/^(tev1|nimble)(:|$)/.test(B)&&E.decisionModels?"systemone":"chat"};return{...A,embedding:B}}function GBQ(A,Q,B){let E=bJ(A.kind,{decisionModels:A.decisionModels,memoryBytes:B}),I=Q==="chat"?E.chat:Q==="vision"?E.vision:Q==="classifier"?E.classifier:E.embedding,D=A.models.filter((J)=>Q==="embedding"?J.capabilities.includes("embedding")||/embed/i.test(J.id):!J.capabilities.includes("embedding")||J.capabilities.includes("completion")).map((J)=>J.id);return[...new Set([...D,...lE(A,I)?[]:[I]])]}function Q3A({columns:A,rows:Q,previous:B,onDone:E,onQuit:I,deps:D={}}){let[J,G]=jB.useState({kind:"welcome"}),U=jB.useRef([]),[Y,H]=jB.useState(0),[X,N]=jB.useState(B?.mode==="local"?B.placements:{...$8}),[z,F]=jB.useState(B?.runtime?.kind??"docker"),[V,O]=jB.useState(null),[j,b]=jB.useState(null),[x,v]=jB.useState({}),[w,k]=jB.useState(null),[h,t]=jB.useState(B?.models??null),[i,UA]=jB.useState(null),[CA,GA]=jB.useState({}),[iA,jA]=jB.useState(A2),IQ=Kz(),[_A,RB]=jB.useState({name:[B?.account?.firstName??IQ.firstName,B?.account?.lastName].filter(Boolean).join(" "),email:B?.account?.email??IQ.email,company:B?.account?.company??"",password:""}),[YA,yA]=jB.useState(null),[YQ,yQ]=jB.useState(!1);jB.useEffect(()=>{sQ().then((p)=>yQ(!!p.hosts[t0]?.credential),()=>{return})},[]);let[zQ,uA]=jB.useState({}),[sA,qQ]=jB.useState(""),[YB]=jB.useState(()=>{try{return(D.source??(()=>kC({remembered:B?.runtime?.sourceDir})))()}catch{return null}}),tA=jB.useRef(null);jB.useEffect(()=>()=>tA.current?.abort(),[]);let WQ=jB.useCallback((p,IA={})=>{G((SA)=>{if(!IA.replace)U.current.push(SA);return p}),H(0)},[]),EQ=jB.useCallback(()=>{let p=U.current.pop();if(p)G(p),H(0)},[]),AB=Uz(X,z),fB=jB.useRef(null),B0=jB.useCallback((p=!1)=>{let IA=(D.detect??(()=>p4()))().catch(()=>[]);fB.current=IA,IA.then((SA)=>{O(SA),v(Object.fromEntries(SA.filter((TA)=>!TA.running).map((TA)=>[TA.kind,(D.canStart??j9)(TA.kind)])));let mA=SA.findIndex((TA)=>TA.running&&TA.server);if(p&&mA>0)H(mA)})},[D]),i0=jB.useCallback(()=>{O(null),B0(!0)},[B0]);jB.useEffect(()=>{B0()},[B0]);let rQ=()=>WQ({kind:"review"}),hB=()=>{if(X.account==="local")jA(Q2(_A.name)),WQ({kind:"account",index:0});else rQ()},MB=()=>{if(AB.length)jA(A2),WQ({kind:"cloud",index:0});else hB()},KB=(p=X)=>{if(cE(p))i0(),WQ({kind:"servers"});else if(Uz(p,z).length)jA(A2),WQ({kind:"cloud",index:0});else if(p.account==="local")jA(Q2(_A.name)),WQ({kind:"account",index:0});else WQ({kind:"review"})},X0=async(p)=>{await Y8({mode:"cloud",host:t0,placements:{...SJ}});let IA=await sQ();IA.defaultHost=t0,IA.preferences={...IA.preferences,askAi:p??IA.preferences?.askAi??{kind:"oatmilk"}},await FI(IA),E({host:t0,mode:"cloud",signedIn:!1})},v0=async(p,IA=!1)=>{if(yA(p),p==="more"){WQ({kind:"more"});return}if(!IA&&p==="cloud"&&B?.mode==="local"){WQ({kind:"move-note",target:"cloud",next:p});return}if(!IA&&["local","local-ai","custom"].includes(p)&&(B?.mode==="cloud"||YQ)){WQ({kind:"move-note",target:"local",next:p});return}if(p==="cloud"){let TA=(await(fB.current??Promise.resolve(V??[]))).map((eA)=>eA.running&&eA.server?{server:eA.server,model:vIA(eA.server.models)}:null).find((eA)=>eA?.model);if(TA?.model){WQ({kind:"ai-here",server:TA.server,model:TA.model});return}await X0();return}if(p==="remote"){jA(Q2("http://localhost:3000")),WQ({kind:"remote"});return}if(p==="custom"){WQ({kind:"parts"});return}let SA={...[...Au,...Qu].find((mA)=>mA.id===p).placements};if(N(SA),p==="local-ai"&&YB&&!Yz(YB).length)F("source");KB(SA)},nB=async(p)=>{let IA=kJ(p);k(p);let SA=B?.models?.server===p.kind&&B.models.baseUrl===p.baseUrl?B.models:null;t(SA??IA.models),UA(null),WQ({kind:"models"})},j0=()=>{let p={...X};for(let SA of wC)if(p[SA]==="local")p[SA]="cloud";if(N(p),Uz(p,z).length)jA(A2),WQ({kind:"cloud",index:0});else hB()},SQ=()=>{tA.current?.abort();let p=new AbortController;tA.current=p,uA({}),qQ(""),WQ({kind:"installing"},{replace:J.kind==="failed"});let[IA,...SA]=_A.name.trim().split(/\s+/),mA={choices:{placements:X,runtime:z,models:cE(X)?h??void 0:void 0,cloud:CA},sourceDir:YB??void 0,download:!0,pullModels:!0,account:X.account==="local"?{email:_A.email.trim().toLowerCase(),firstName:IA||"Me",lastName:SA.join(" ")||void 0,company:_A.company.trim(),password:_A.password||void 0}:void 0},TA={onStep:(eA)=>{if(!p.signal.aborted)uA((NB)=>({...NB,[eA.step]:eA}))},onLine:(eA,NB)=>{if(!p.signal.aborted)qQ(NB)}};(D.install??((eA,NB)=>Fz(eA,NB,{signal:p.signal})))(mA,TA).then((eA)=>{if(!p.signal.aborted)G({kind:"done",result:eA})},(eA)=>{if(!p.signal.aborted)G({kind:"failed",message:CQ(eA),hint:eA instanceof n?eA.hint:void 0})})},gB=async(p)=>{let IA;try{IA=q1(p)}catch(TA){G({kind:"remote",error:CQ(TA)});return}if(G({kind:"remote",checking:!0}),!await(D.health??n4)(IA)){G({kind:"remote",error:`Nothing answers as Oatmilk at ${IA}. Is it running?`});return}await Y8({mode:"remote",host:IA,placements:{...SJ}});let mA=await sQ();mA.defaultHost=IA,await FI(mA),E({host:IA,mode:"remote",signedIn:!!mA.hosts[IA]?.credential})},h0=(p)=>{let IA=AB[p],SA=iA.value.trim();if(!SA&&!IA.optional&&B?.mode!=="local"){G({kind:"cloud",index:p,error:`Enter the ${IA.label.split(" (")[0]}.`});return}let mA=SA?OIA(CA,IA.key,SA):CA;if(GA(IA.key==="s3.endpoint"&&SA?{...mA,s3:{...mA.s3,forcePathStyle:!0}}:mA),jA(A2),p+1<AB.length)WQ({kind:"cloud",index:p+1});else hB()},LI=(p)=>{let IA=B2[p],SA=iA.value.trim();if(IA==="name"&&!SA){G({kind:"account",index:p,error:"Enter your name."});return}if(IA==="company"&&(SA.length<2||SA.length>100)){G({kind:"account",index:p,error:"Enter your company's name (2 to 100 characters)."});return}let mA={..._A,[IA]:SA};if(RB(mA),p+1<B2.length)jA(Q2(mA[B2[p+1]])),WQ({kind:"account",index:p+1});else rQ()},Z0=WK(X,z),cI=fI.length+1,G0=[...(V??[]).map((p)=>({kind:"probe",probe:p})),{kind:"url"},{kind:"cloud"}],KI=w&&h?vC(w,h):[],n0=w?.kind!=="ollama"?KI:[];iQ((p,IA)=>{let SA=IA.upArrow||p==="k",mA=IA.downArrow||p==="j";if(J.kind==="welcome"||J.kind==="more"){let TA=J.kind==="welcome"?Au:Qu;if(SA)H((eA)=>Math.max(0,eA-1));else if(mA)H((eA)=>Math.min(TA.length-1,eA+1));else if(/^[1-9]$/.test(p)&&Number(p)<=TA.length)v0(TA[Number(p)-1].id);else if(IA.return)v0(TA[Y].id);else if(J.kind==="more"&&IA.escape)EQ();else if(p==="q"||IA.escape)I();return}if(J.kind==="move-note"){if(IA.return)v0(J.next,!0);else if(IA.escape)EQ();return}if(J.kind==="ai-here"){if(SA||mA)H((TA)=>TA===0?1:0);else if(IA.return||p==="y"||p==="n"){let TA=p==="y"||IA.return&&Y===0;X0(TA?{kind:"local",server:J.server.kind,baseUrl:J.server.baseUrl,model:J.model}:{kind:"oatmilk"})}else if(IA.escape)EQ();return}if(J.kind==="parts"){if(SA)H((TA)=>Math.max(0,TA-1));else if(mA)H((TA)=>Math.min(cI-1,TA+1));else if(IA.leftArrow||IA.rightArrow||p===" "||p==="h"||p==="l"){let TA=IA.leftArrow||p==="h"?-1:1;if(Y===fI.length)F((eA)=>eA==="docker"?"source":"docker");else{let eA=fI[Y];N((NB)=>({...NB,[eA.id]:lw(eA.id,NB[eA.id],TA)}))}}else if(IA.return&&!Z0.length)KB();else if(IA.escape)EQ();return}if(J.kind==="remote"||J.kind==="server-url"||J.kind==="cloud"||J.kind==="account"){if(IA.escape){EQ();return}if(J.kind==="remote"&&J.checking)return;let TA=J.kind==="cloud"?4000:300,eA=BI(iA,p,IA,TA);if(eA.type==="edit"){jA(eA.state);return}if(eA.type!=="submit")return;if(J.kind==="remote")gB(iA.value);else if(J.kind==="cloud")h0(J.index);else if(J.kind==="account")LI(J.index);else{let NB;try{NB=vJ(iA.value)}catch(n1){G({kind:"server-url",error:CQ(n1)});return}(D.inspect??hI)("openai-compatible",NB).then((n1)=>nB(n1),()=>G({kind:"server-url",error:`Nothing answers with the OpenAI API at ${NB}.`}))}return}if(J.kind==="servers"){if(p==="r"){i0();return}let TA=G0[Y];if(p==="s"&&V&&TA?.kind==="probe"&&!TA.probe.running&&!j&&x[TA.probe.kind]){let eA=TA.probe.kind;b({kind:eA}),(D.startServer??((NB)=>R9(NB,{listenAll:z==="docker"&&process.platform==="linux"})))(eA).then((NB)=>{if(b(NB?null:{kind:eA,failed:!0}),NB)i0()},()=>b({kind:eA,failed:!0}));return}if(IA.escape){EQ();return}if(!V)return;if(SA)H((eA)=>Math.max(0,eA-1));else if(mA)H((eA)=>Math.min(G0.length-1,eA+1));else if(IA.return){let eA=G0[Y];if(eA.kind==="url")jA(Q2("http://localhost:8000/v1")),WQ({kind:"server-url"});else if(eA.kind==="cloud")j0();else if(eA.probe.server)nB(eA.probe.server)}return}if(J.kind==="models"&&w&&h){if(SA)H((TA)=>Math.max(0,TA-1));else if(mA)H((TA)=>Math.min(SM.length-1,TA+1));else if(IA.leftArrow||IA.rightArrow||p==="h"||p==="l"){let TA=SM[Y],eA=GBQ(w,TA.id),NB=TA.id==="embedding"?[void 0,...eA]:eA,n1=NB.indexOf(A3A(h,TA.id)),j$=NB[(n1+(IA.leftArrow||p==="h"?-1:1)+NB.length)%NB.length];t(JBQ(h,TA.id,j$,w))}else if(p==="t")UA(`Asking ${h.chat}… (the first answer loads it into memory)`),(D.check??Xz)(w.baseUrl,h.chat).then((TA)=>UA(TA.ok?`${hA.done} ${h.chat} answered in ${(TA.ms/1000).toFixed(1)} s`:`${hA.failed} ${TA.problem??"No answer"}`));else if(p==="r")(D.inspect??hI)(w.kind,w.baseUrl).then((TA)=>k(TA),()=>{return});else if(IA.return&&!n0.length)MB();else if(IA.escape)EQ();return}if(J.kind==="review"){if(IA.return)SQ();else if(p==="e")WQ({kind:"parts"});else if(IA.escape)EQ();return}if(J.kind==="failed"){if(p==="r"||IA.return)SQ();else if(IA.escape)G({kind:"review"});else if(p==="q")I();return}if(J.kind==="done"&&IA.return)E({host:J.result.host,mode:"local",signedIn:J.result.signedIn})});let bA=Math.max(30,Math.min(A-4,92)),BA=["parts","review","installing","failed"].includes(J.kind),XA=d(e,{flexDirection:"column",alignItems:"center",marginBottom:1,children:[Q>=30?R(rh,{columns:A,animate:!1}):d(f,{bold:!0,color:L.accent,children:[hA.brand," oatmilk"]}),BA?R(e,{marginTop:1,children:R(PM,{percent:U8(X)})}):null]}),$Q=DBQ(IBQ(YA,X,AB.length,cE(X)),EBQ(J)),kQ=(p,IA,SA)=>d(e,{width:A,height:Q,flexDirection:"column",alignItems:"center",justifyContent:"center",children:[XA,d(e,{flexDirection:"column",width:bA,children:[$Q?R(f,{color:L.muted,children:`${$Q.current}/${$Q.total}`}):null,R(f,{bold:!0,wrap:"wrap",children:p}),R(e,{flexDirection:"column",marginTop:1,children:IA}),R(e,{marginTop:1,children:R(f,{color:L.faint,wrap:"truncate-end",children:SA})})]})]});if(J.kind==="welcome"||J.kind==="more"){let p=J.kind==="welcome"?Au:Qu,IA=p[Math.min(Y,p.length-1)];return kQ(J.kind==="welcome"?"Welcome to Oatmilk. How do you want to use it?":"More ways to run Oatmilk",d(PB,{children:[p.map((SA,mA)=>d(f,{color:mA===Y?L.focus:SA.id==="more"?L.muted:L.text,bold:mA===Y,wrap:"truncate-end",children:[mA===Y?`${hA.pointer} `:" ",SA.label]},SA.id)),R(e,{marginTop:1,children:R(f,{color:L.muted,wrap:"wrap",children:IA.detail})})]}),J.kind==="welcome"?"↑↓ choose · ⏎ continue · q quit":"↑↓ choose · ⏎ continue · Esc back")}if(J.kind==="move-note"){let p=J.target==="cloud";return kQ(p?"Your books on this computer stay here":"Your books in Oatmilk Cloud stay there",d(e,{flexDirection:"column",children:[R(f,{wrap:"wrap",children:p?"Oatmilk Cloud has its own books, and nothing on this computer moves there by itself.":"This makes a new Oatmilk on this computer, and nothing in Oatmilk Cloud moves here by itself."}),R(e,{marginTop:1,children:R(f,{color:L.muted,wrap:"wrap",children:p?"Keep a copy first with oatmilk export --local. The Oatmilk here keeps running until you stop it with oatmilk local stop, and oatmilk --local still opens it.":"Keep a copy first with oatmilk export --cloud. Your cloud account stays signed in, and oatmilk --cloud still opens it."})})]}),"⏎ continue · Esc back")}if(J.kind==="ai-here"){let p=pB[J.server.kind];return kQ("Use the AI on this computer?",d(PB,{children:[R(e,{children:R(f,{color:L.muted,wrap:"wrap",children:`${p} is running here with ${J.model}. Ask AI in the terminal can use it: your books stay in Oatmilk, and your questions and answers stay on this computer.`})}),R(e,{marginTop:1,flexDirection:"column",children:[`Yes, use ${J.model}`,"No, use Oatmilk's AI"].map((IA,SA)=>d(f,{color:SA===Y?L.focus:L.text,bold:SA===Y,children:[SA===Y?`${hA.pointer} `:" ",IA]},IA))})]}),"↑↓ choose · ⏎ continue · Esc back · change it any time with /model")}if(J.kind==="parts"){let IA=fI[Y];return kQ("Where should each part run? Oatmilk itself runs on this computer.",d(PB,{children:[fI.map((SA,mA)=>{let TA=X[SA.id],eA=TA==="local"?L.success:TA==="cloud"?L.warning:L.muted;return d(f,{wrap:"truncate-end",color:mA===Y?L.focus:L.text,children:[mA===Y?`${hA.pointer} `:" ",SA.label.padEnd(20),R(f,{color:eA,children:`‹ ${wJ(TA)} ›`.padEnd(18)}),R(f,{color:L.muted,children:SA.about})]},SA.id)}),d(f,{wrap:"truncate-end",color:Y===fI.length?L.focus:L.text,children:[Y===fI.length?`${hA.pointer} `:" ","How it runs".padEnd(20),R(f,{color:L.info,children:`‹ ${z==="docker"?"Docker":"From source"} ›`.padEnd(18)}),R(f,{color:L.muted,children:z==="docker"?"recommended: the full app in containers":"bun run dev in your checkout"})]}),R(e,{marginTop:1,children:R(f,{color:Z0.length?L.danger:L.muted,wrap:"wrap",children:Z0[0]??(Y<fI.length?IA.options[X[IA.id]]:z==="docker"?"Docker builds and runs Oatmilk with its database and file storage. The first build takes about 10 minutes.":"Runs bun run dev from your Oatmilk checkout, with hot reload. For people working on Oatmilk.")})})]}),"↑↓ choose · ←→ change · ⏎ continue · Esc back")}if(J.kind==="remote")return kQ("Which Oatmilk should the terminal use?",d(PB,{children:[R(e,{borderStyle:"single",borderColor:L.focus,paddingX:1,children:R(p0,{state:iA,width:bA-4,placeholder:"https://books.example.com"})}),J.checking?R(f0,{label:"Checking it answers…"}):J.error?R(f,{color:L.danger,wrap:"wrap",children:J.error}):R(f,{color:L.muted,children:"A self-hosted Oatmilk, or http://localhost:3000 for bun run dev."})]}),"⏎ connect · Esc back");if(J.kind==="servers")return kQ("Which model server should run Oatmilk's AI?",!V?R(f0,{label:"Looking for Ollama and LM Studio on this computer…"}):d(PB,{children:[G0.map((p,IA)=>{let SA=IA===Y,mA=SA?`${hA.pointer} `:" ";if(p.kind==="url")return d(f,{color:SA?L.focus:L.text,children:[mA,"Another server (vLLM, llama.cpp, LocalAI…)"]},"url");if(p.kind==="cloud")return d(f,{color:SA?L.focus:L.text,children:[mA,"Use cloud models instead ",R(f,{color:L.muted,children:"(Vercel AI Gateway)"})]},"cloud");let{probe:TA}=p;return d(f,{color:SA?L.focus:TA.running?L.text:L.muted,wrap:"truncate-end",children:[mA,R(f,{color:TA.running?L.success:L.faint,children:TA.running?"●":"○"})," ",TA.label,TA.server?.version?` ${TA.server.version}`:""," ",R(f,{color:L.muted,children:TA.running?`${TA.server?.models.length??0} models · ${TA.baseUrl}`:"not running"})]},TA.kind)}),(()=>{let p=G0[Y];if(p?.kind==="probe"&&j?.kind===p.probe.kind&&!j.failed)return R(e,{marginTop:1,children:R(f0,{label:`Starting ${p.probe.label}…`})});if(p?.kind==="probe"&&!p.probe.running)return R(e,{marginTop:1,children:d(f,{color:L.warning,wrap:"wrap",children:[j?.kind===p.probe.kind?`${p.probe.label} didn't start. `:"",x[p.probe.kind]?`Press s to start ${p.probe.label} now${p.probe.kind==="ollama"?" (with a context long enough for statements)":""}, or start it yourself and press r.`:`${tI(p.probe.kind)} Then press r.`]})});if(p?.kind==="probe"&&p.probe.server&&!p.probe.server.models.length)return R(e,{marginTop:1,children:d(f,{color:L.muted,wrap:"wrap",children:["No models yet: Oatmilk ",p.probe.kind==="ollama"?"downloads the recommended ones during setup":`needs one first: ${pE(p.probe.kind,bJ(p.probe.kind).chat)}`,"."]})});return null})()]}),"↑↓ choose · ⏎ continue · s start it · r look again · Esc back");if(J.kind==="server-url")return kQ("Your server's OpenAI-compatible address",d(PB,{children:[R(e,{borderStyle:"single",borderColor:L.focus,paddingX:1,children:R(p0,{state:iA,width:bA-4,placeholder:"http://localhost:8000/v1"})}),J.error?R(f,{color:L.danger,wrap:"wrap",children:J.error}):R(f,{color:L.muted,children:"It must answer /v1/models and /v1/chat/completions."})]}),"⏎ continue · Esc back");if(J.kind==="models"&&w&&h){let p=SM[Y];return kQ(`Models on ${pB[w.kind]}`,d(PB,{children:[SM.map((IA,SA)=>{let mA=A3A(h,IA.id),TA=X[IA.part]==="local",eA=mA?!!lE(w,mA):!0,NB=!TA?"in the cloud":!mA?"off":eA?"installed":w.kind==="ollama"?"downloads during setup":"not on the server";return d(f,{wrap:"truncate-end",color:SA===Y?L.focus:TA?L.text:L.muted,children:[SA===Y?`${hA.pointer} `:" ",IA.label.padEnd(20),R(f,{children:`‹ ${mA??"none"} ›`.padEnd(30)}),R(f,{color:!TA?L.faint:eA?L.success:w.kind==="ollama"?L.warning:L.danger,children:NB})]},IA.id)}),d(e,{marginTop:1,flexDirection:"column",children:[n0.length?d(f,{color:L.danger,wrap:"wrap",children:["Download first: ",n0.map((IA)=>pE(w.kind,IA)).join(" · "),", then press r."]}):null,i?R(f,{color:i.startsWith(hA.failed)?L.danger:L.muted,wrap:"wrap",children:i}):R(f,{color:L.muted,wrap:"wrap",children:p.id==="classifier"?h.classifierApi==="systemone"?"A decision model answers classifiers with calibrated confidence, like TypeSafe's Jev.":"A chat model answers classifiers as structured JSON. Steps that need confidence, like matching receipts, wait for you.":p.id==="vision"?"Reads receipts, statements and PDFs. Pick a model that sees images.":p.id==="embedding"?"Optional: ranks search results.":"Answers Ask AI and runs the agents. Pick one that calls tools."})]})]}),"↑↓ choose · ←→ change model · t test · r refresh · ⏎ continue · Esc back")}if(J.kind==="cloud"){let p=AB[J.index];if(!p)return kQ("",null,"");return kQ(`${p.label}`,d(PB,{children:[R(e,{borderStyle:"single",borderColor:L.focus,paddingX:1,children:R(p0,{state:iA,width:bA-4,mask:p.secret,placeholder:p.optional?"optional":B?.mode==="local"?"empty keeps the saved one":""})}),J.error?R(f,{color:L.danger,children:J.error}):R(f,{color:L.muted,children:"Kept only in the local Oatmilk's settings file."})]}),"⏎ next · Esc back")}if(J.kind==="account"){let p=B2[J.index];return kQ(BBQ[p],d(PB,{children:[R(e,{borderStyle:"single",borderColor:L.focus,paddingX:1,children:R(p0,{state:iA,width:bA-4,placeholder:p==="company"?"Acme Inc.":""})}),J.error?R(f,{color:L.danger,children:J.error}):R(f,{color:L.muted,children:"Nothing here leaves this computer."})]}),"⏎ next · Esc back")}if(J.kind==="review")return kQ("Ready to set up",d(PB,{children:[fI.map((p)=>{let IA=X[p.id];return d(f,{wrap:"truncate-end",children:[" ",p.label.padEnd(20),R(f,{color:IA==="local"?L.success:IA==="cloud"?L.warning:L.muted,children:wJ(IA).padEnd(16)}),R(f,{color:L.muted,children:p.options[IA]})]},p.id)}),d(e,{marginTop:1,flexDirection:"column",children:[d(f,{color:L.muted,wrap:"wrap",children:["Runs ",z==="docker"?"in Docker at https://oatmilk.localhost (the first build takes about 10 minutes)":"from source with bun run dev at http://localhost:3000",YB?` from ${YB}`:", from a copy of Oatmilk's source the CLI downloads","."]}),cE(X)&&h?d(f,{color:L.muted,wrap:"truncate-end",children:["Models: ",pB[h.server]," · ",[h.chat,h.classifier,h.vision].filter(Boolean).join(" · ")]}):null,X.account==="local"?d(f,{color:L.muted,wrap:"truncate-end",children:["You: ",_A.name," · ",_A.company," · signed in here as ",_A.email]}):R(f,{color:L.muted,children:"You sign in with your cloud account once it's running."}),RK(B,X)?R(e,{marginTop:1,children:R(f,{color:L.warning,wrap:"wrap",children:"Your books and files don't move to their new place by themselves. Back them up first with oatmilk local backup."})}):null]})]}),"⏎ set up · e change parts · Esc back");if(J.kind==="installing"||J.kind==="failed"){let p=["tools","source","models","settings","packages","start","ready","reach","account","signin","company"];return kQ(J.kind==="failed"?"Setup stopped":"Setting up Oatmilk on this computer",d(PB,{children:[p.map((IA)=>{let SA=zQ[IA],mA=!SA?R(f,{color:L.faint,children:hA.pending}):SA.status==="running"?R(f0,{}):SA.status==="done"?R(f,{color:L.success,children:hA.done}):SA.status==="skipped"?R(f,{color:L.faint,children:"–"}):SA.status==="warning"?R(f,{color:L.warning,children:"!"}):R(f,{color:L.danger,children:hA.failed});return d(e,{gap:1,children:[mA,d(f,{color:SA?L.text:L.muted,wrap:"truncate-end",children:[qz[IA],SA?.detail&&SA.status!=="failed"&&SA.status!=="warning"?R(f,{color:L.muted,children:` ${SA.detail}`}):null]})]},IA)}),R(e,{marginTop:1,flexDirection:"column",children:J.kind==="failed"?d(PB,{children:[R(f,{color:L.danger,wrap:"wrap",children:J.message}),J.hint?R(f,{color:L.muted,wrap:"wrap",children:J.hint}):null]}):R(f,{color:L.faint,wrap:"truncate-end",children:sA||" "})})]}),J.kind==="failed"?"r try again · Esc change choices · q quit":"Keep this open; ⌃C stops setup")}if(J.kind!=="done")return kQ("Your models",R(f0,{label:"Reading the model server…"}),"Esc back");let gA=J.result;return kQ("Oatmilk is ready",d(PB,{children:[d(f,{children:[R(f,{color:L.success,children:hA.done})," Running at ",R(f,{bold:!0,children:gA.host})]}),gA.signedIn?d(f,{children:[R(f,{color:L.success,children:hA.done})," Signed in as ",_A.email,_A.company?` · ${_A.company}`:""]}):R(f,{color:L.muted,children:"Next: sign in with your cloud account."}),gA.warnings.map((p)=>d(f,{color:L.warning,wrap:"wrap",children:["! ",p]},p)),gA.generatedPassword?d(f,{color:L.muted,wrap:"wrap",children:["For the browser, sign in as ",_A.email," with ",R(f,{color:L.text,children:gA.generatedPassword})," (see it again: oatmilk local password)."]}):null,R(f,{color:L.muted,wrap:"wrap",children:"Manage it with oatmilk local, the models with oatmilk models, and see the gauge with oatmilk status."})]}),`⏎ open ${TI(gA.host)}`)}var jB,Au,Qu,SM,B2,BBQ,A2,Q2=(A)=>({value:A,cursor:A.length});var B3A=W(async()=>{wQ();F1();S0();fJ();Mz();xJ();TK();Z4();K8();RD();bB();HQ();await $0([dB(),gD(),eh(),tH(),vD()]);jB=pA(JQ(),1),Au=[{id:"cloud",label:"Sign in to Oatmilk",detail:"Use your account at getoatmilk.com, or make one. Nothing to install.",placements:SJ},{id:"local",label:"Keep everything on this computer",detail:"Your books, files and AI stay here, with no account to make. It needs Docker, and the first start takes about 10 minutes.",placements:$8},{id:"more",label:"More options",detail:"Choose for each part, use your own cloud services, or connect to an Oatmilk you run.",placements:null}],Qu=[{id:"custom",label:"Choose for each part",detail:"Keep what you want on this computer, and use the cloud for the rest.",placements:null},{id:"local-ai",label:"Your own cloud, with AI here",detail:"Your own sign-in (Clerk), database and file storage, with every model running on this computer.",placements:mw},{id:"remote",label:"Connect to an Oatmilk you run",detail:"A server you or your team run, or bun run dev on this computer.",placements:null}],SM=[{id:"chat",label:"Ask AI & agents",part:"agents"},{id:"vision",label:"Reading documents",part:"documents"},{id:"classifier",label:"Classifiers",part:"classifiers"},{id:"embedding",label:"Embeddings",part:"agents"}],B2=["name","company"],BBQ={name:"What's your name?",company:"What's your company called?"};A2={value:"",cursor:0}});var J3A={};pQ(J3A,{offlineEnabled:()=>CBQ,localTarget:()=>E3A,isPrivateAddress:()=>D3A,ensureLocalReady:()=>dU,autoSignIn:()=>I2,assertOffline:()=>$BQ});import{isIP as I3A}from"node:net";async function E3A(A){let Q=await $I();if(!Q||Q.mode!=="local"||!Q.runtime||Q.host!==A)return null;return{profile:Q,platform:new i4(Q.runtime)}}async function dU(A,Q){let B=await E3A(A);if(!B)return null;if(await B.platform.trustCertificate().catch(()=>!1),await n4(A))return B;if(!Q.start)throw new n(`Your local Oatmilk at ${A} isn't running.`,y.failure,"Start it with: oatmilk local start");if(Q.onStatus?.("Starting your local Oatmilk…"),await B.platform.start((I)=>Q.onStatus?.(I)),!await SK(A,{timeoutMs:Q.timeoutMs??600000,signal:Q.signal,onWait:(I)=>{if(I>3000)B.platform.trustCertificate().catch(()=>!1);Q.onStatus?.(`Starting your local Oatmilk… ${Math.round(I/1000)} s`)}}))throw new n(`Your local Oatmilk didn't start at ${A}.`,y.failure,"See why with: oatmilk local logs");return B}async function I2(A,Q){let B=(await sQ()).hosts[A];if(B?.credential||!B?.localAccount)return!1;let E=await s8({host:A,email:B.localAccount.email,password:B.localAccount.password,signal:Q});return await zB(A,(I)=>({...I,credential:E})),!0}function D3A(A){let{hostname:Q}=new URL(A),B=Q.replace(/^\[|\]$/g,"").toLowerCase();if(W_(B)||B.endsWith(".local")||B.endsWith(".lan")||B.endsWith(".internal")||B.endsWith(".home.arpa"))return!0;if(I3A(B)===6)return B==="::1"||B.startsWith("fc")||B.startsWith("fd")||B.startsWith("fe80");if(I3A(B)!==4)return!1;let[E,I]=B.split(".").map(Number);return E===127||E===10||E===192&&I===168||E===172&&I>=16&&I<=31||E===169&&I===254}function CBQ(A,Q=process.env){return A||Q.OATMILK_OFFLINE==="1"||Q.OATMILK_OFFLINE==="true"}function $BQ(A){if(!D3A(A))throw new n(`--offline keeps Oatmilk on this computer and its network, and ${A} is on the internet.`,y.usage,"Use your local Oatmilk (oatmilk --local), or leave out --offline.")}var wM=W(()=>{Q5();wQ();j_();S0();Z4();K8()});function G3A(A){let Q=A.inputSchema.properties??{},B=(A.inputSchema.required??[]).filter((I)=>I!=="idempotencyKey");if(!B.length)return"{}";let E=(I)=>I.enum?.[0]??(I.default!==void 0?I.default:I.type==="integer"||I.type==="number"?0:I.type==="boolean"?!1:I.type==="array"?[]:I.type==="object"?{}:"");return JSON.stringify(Object.fromEntries(B.map((I)=>[I,E(Q[I]??{})])),null,2)}function UBQ(A,Q){return(JSON.stringify(A,null,2)??"null").split(`
514
+ `)){let F=z,V=Y;if(!F)U.push({text:"",start:V});while(F.length){let O=cH(F,D-1)[0]||[...F][0];U.push({text:O,start:V}),V+=O.length,F=F.slice(O.length)}Y+=z.length+1}let H=U.length-1;for(let z=0;z<U.length;z+=1){let F=U[z].start+U[z].text.length;if(G>=U[z].start&&G<=F){H=z;break}}let X=B.maxRows??U.length,N=Math.max(0,Math.min(H-X+1,U.length-X));return U.slice(N,N+X).map((z,F)=>{let V=F===0&&N===0?E:E.map((x)=>({...x,text:" ".repeat(Fh(x.text))}));if(!B.focused||N+F!==H)return[...V,{text:z.text}];let O=G-z.start,j=z.text.slice(0,O),b=[...z.text.slice(O)][0]??" ";return[...V,{text:j},{text:b,inverse:!0},{text:z.text.slice(O+(b===" "&&O>=z.text.length?0:b.length))}]})}function p0({state:A,width:Q,placeholder:B,focused:E=!0,maxRows:I,prefix:D,mask:J}){let G=gh(A,Q,{placeholder:B,focused:E,maxRows:I,prefix:D,mask:J});return R(e,{flexDirection:"column",children:G.map((U,Y)=>R(O4,{line:U},Y))})}var gD=W(async()=>{bB();HQ();await $0([dB(),g8()])});import{mkdirSync as OAQ,readFileSync as LAQ,writeFileSync as WAQ}from"node:fs";import{join as HXA}from"node:path";function NXA(A=qI()){try{let Q=JSON.parse(LAQ(HXA(A,XXA),"utf8"));return Array.isArray(Q)?Q.filter((B)=>typeof B==="string").slice(-ZXA):[]}catch{return[]}}function zXA(A,Q=qI()){try{OAQ(Q,{recursive:!0,mode:448}),WAQ(HXA(Q,XXA),JSON.stringify(A.slice(-ZXA)),{mode:384})}catch{return}}var XXA="history.json",ZXA=200;var qXA=W(()=>{AJ()});function jAQ(A){if(!/^\/\S*$/.test(A))return[];let Q=A.slice(1).toLowerCase();return FXA.filter((B)=>B.name.startsWith(Q)).concat(FXA.filter((B)=>!B.name.startsWith(Q)&&B.name.includes(Q)))}function MXA({onHeight:A,onSlash:Q}){let B=FB(),E=HG(B.chat),[I,D]=TD.useState({value:"",cursor:0}),[J,G]=TD.useState(0),U=TD.useRef(null);U.current??=new Rh(NXA());let Y=B.focus==="composer",H=B.layout.columns-4,X=Y?jAQ(I.value):[],N=E.pending,z=TD.useMemo(()=>{if(!N)return null;for(let t of E.snapshot.data.messages)for(let i of t.parts)if(i.type==="dynamic-tool"&&i.toolCallId===N.toolCallId)return i;return null},[N,E.snapshot]),F=N?N.request.kind==="tool-approval"?[{id:"approve",label:"Approve"},{id:"deny",label:"Don't allow"}]:YM(N.request):[],V=!!N&&!I.value,O=(t)=>{let i=t.trim();if(!i)return;if(U.current?.add(i),zXA(U.current?.all??[]),D({value:"",cursor:0}),i.startsWith("/")){let[UA,...CA]=i.slice(1).split(/\s+/);Q(UA.toLowerCase(),CA.join(" "));return}B.ask(i)};iQ((t,i)=>{if(i.escape){if(X.length&&I.value.startsWith("/")){D({value:"",cursor:0});return}if(E.busy){B.chat.cancel(),B.toast("Stopping…","info");return}B.setFocus("main");return}if(i.tab&&X.length){let CA=X[Math.min(J,X.length-1)];D({value:`/${CA.name} `,cursor:CA.name.length+2});return}if(i.tab){B.setFocus(i.shift?"main":B.layout.sidebarWidth?"sidebar":"main");return}if(X.length&&(i.upArrow||i.downArrow)){G((CA)=>(CA+(i.upArrow?-1:1)+X.length)%X.length);return}if(X.length&&i.return&&!i.meta&&!i.shift){let CA=X[Math.min(J,X.length-1)],GA=I.value.slice(1).split(/\s+/)[0];O(GA===CA.name?I.value:`/${CA.name}`);return}if(V&&F.length){if(i.upArrow||i.downArrow){B.chat.moveOption(i.upArrow?-1:1,F.length);return}let CA=/^[1-9]$/.test(t)?Number(t)-1:-1,GA=i.return?F[E.option]:CA>=0?F[CA]:N?.request.kind==="tool-approval"&&/^[yn]$/i.test(t)?F[t.toLowerCase()==="y"?0:1]:void 0;if(GA&&N){B.chat.respond([{requestId:N.request.requestId,optionId:GA.id}]).catch((iA)=>B.toast(String(iA?.message??iA),"danger"));return}}if(i.pageUp||i.pageDown)return;let UA=BI(I,t,i,U$);if(UA.type==="submit")O(I.value);else if(UA.type==="edit")D(UA.state),G(0);else if(UA.type==="history"){let CA=U.current?.move(UA.direction,I.value);if(CA!==null&&CA!==void 0)D({value:CA,cursor:CA.length})}},{isActive:Y}),z8((t)=>D((i)=>j4(i,t,U$)),{isActive:Y});let j=E.resuming?"Picking up where you left off…":N?.request.kind==="tool-approval"?"y to approve · n to decline · or type a message":N?"Choose with ↑↓ and ⏎, or type your own answer…":!B.aiEnabled?"Ask AI is off (--no-ai). Type / for commands":B.focusRecord?`Ask about ${B.focusRecord.label}…`:"Ask Oatmilk anything, or type / for commands",b=[{text:`${hA.prompt} `,color:Y?L.accent:L.faint,bold:!0}],x=gh(I,H,{placeholder:j,focused:Y,maxRows:RAQ,prefix:b}),v=N?.request.kind==="tool-approval"&&z?O8(z,N.request.prompt):null,w=X.slice(0,6),k=(B.focusRecord&&Y?1:0)+(w.length?w.length:0)+(V&&F.length?1+F.length:0),h=x.length+2+k;return TD.useEffect(()=>{A(h)},[h,A]),d(e,{flexDirection:"column",width:B.layout.columns,borderStyle:"single",borderColor:Y?L.focus:L.border,paddingX:1,children:[w.map((t,i)=>d(f,{color:i===Math.min(J,w.length-1)?L.focus:L.muted,children:[i===Math.min(J,w.length-1)?hA.pointer:" "," /",t.name.padEnd(9),R(f,{color:L.faint,children:t.description})]},t.name)),V&&F.length?d(PB,{children:[d(f,{color:L.warning,bold:!0,wrap:"truncate-end",children:[hA.ai," ",v??N?.request.prompt]}),F.map((t,i)=>d(f,{color:i===E.option?L.focus:L.text,wrap:"truncate-end",children:[i===E.option?hA.pointer:" "," ",i+1,". ",t.label,"description"in t&&t.description?d(f,{color:L.faint,children:[" ",t.description]}):null]},t.id))]}):null,B.focusRecord&&Y?d(f,{color:L.faint,wrap:"truncate-end",children:["About: ",R(f,{color:L.muted,children:B.focusRecord.label})]}):null,x.map((t,i)=>R(O4,{line:t},i))]})}var TD,FXA,RAQ=6;var VXA=W(async()=>{l1();L8();K$();RD();BE();pH();qXA();bB();HQ();await $0([dB(),gD(),g8()]);TD=pA(JQ(),1),FXA=[{name:"help",description:"Keys and commands"},{name:"new",description:"Start a new chat"},{name:"chats",description:"Reopen a recent chat"},{name:"model",description:"Where Ask AI thinks: Oatmilk, or Ollama or LM Studio here"},{name:"go",description:"Jump to a page or record (⌃K)"},{name:"search",description:"Search transactions, email, invoices and more"},{name:"run",description:"Run any Oatmilk action"},{name:"org",description:"Switch workspace (personal or a company)"},{name:"theme",description:"Change the theme (/theme dark)"},{name:"update",description:"Update oatmilk to the newest version (⌃U)"},{name:"browser",description:"Open this page in the browser"},{name:"logout",description:"Sign out of this machine"},{name:"quit",description:"Leave Oatmilk"}]});function OXA(A){let[Q,B]=p1.useState(null),E=p1.useRef(A);p1.useEffect(()=>{E.current=A},[A]);let I=p1.useCallback((G)=>{B(G),E.current(!0)},[]),D=p1.useCallback(()=>{B(null),E.current(!1)},[]);return{dialogs:p1.useMemo(()=>({prompt:(G)=>new Promise((U)=>I({kind:"prompt",title:G.title,label:G.label,minLength:G.minLength??0,placeholder:G.placeholder,mask:G.mask,state:{value:G.initial??"",cursor:(G.initial??"").length},resolve:U})),choose:(G)=>new Promise((U)=>I({kind:"choose",title:G.title,items:G.items,filter:{value:"",cursor:0},index:0,resolve:U})),confirm:(G)=>new Promise((U)=>I({kind:"confirm",title:G.title,body:G.body,danger:G.danger??!1,confirmLabel:G.confirmLabel??"Continue",resolve:U})),showSecret:(G,U,Y)=>new Promise((H)=>I({kind:"secret",title:G,secret:U,note:Y,resolve:H}))}),[I]),pending:Q,close:D,update:B}}function _XA(A,Q){let B=Q.toLowerCase().split(/\s+/).filter(Boolean);return A.map((E,I)=>({item:E,index:I})).filter(({item:E})=>B.every((I)=>E.label.toLowerCase().includes(I)||E.detail?.toLowerCase().includes(I))).map(({index:E})=>E)}function LXA({pending:A,close:Q,update:B,width:E,height:I}){let D=Math.min(72,E-4),J=(H)=>{Q(),H()};iQ((H,X)=>{if(A.kind==="prompt"){if(X.escape){J(()=>A.resolve(null));return}let N=BI(A.state,H,X,2000);if(N.type==="submit"){let z=A.state.value.trim();if(z.length<A.minLength){B({...A,error:A.minLength>1?`Write at least ${A.minLength} characters.`:"This can't be empty."});return}J(()=>A.resolve(z))}else if(N.type==="edit")B({...A,state:N.state,error:void 0});return}if(A.kind==="choose"){let N=_XA(A.items,A.filter.value);if(X.escape){J(()=>A.resolve(null));return}if(X.upArrow){B({...A,index:Math.max(0,A.index-1)});return}if(X.downArrow){B({...A,index:Math.min(N.length-1,A.index+1)});return}if(X.return){let F=N[A.index];if(F!==void 0)J(()=>A.resolve(A.items[F].value));return}let z=BI(A.filter,H,X,200);if(z.type==="edit")B({...A,filter:z.state,index:0});return}if(A.kind==="confirm"){if(X.escape||H==="n")J(()=>A.resolve(!1));else if(X.return||H==="y")J(()=>A.resolve(!0));return}if(X.return||X.escape)J(()=>A.resolve())}),z8((H)=>{if(A.kind==="prompt")B({...A,state:j4(A.state,H,2000),error:void 0});if(A.kind==="choose")B({...A,filter:j4(A.filter,H,200),index:0})});let G,U="";if(A.kind==="prompt")U="⏎ save · Esc cancel",G=d(PB,{children:[R(f,{color:L.muted,wrap:"wrap",children:A.label}),R(e,{borderStyle:"single",borderColor:L.focus,paddingX:1,marginTop:1,children:R(p0,{state:A.state,width:D-8,placeholder:A.placeholder,maxRows:4,mask:A.mask})}),A.error?R(f,{color:L.danger,children:A.error}):null]});else if(A.kind==="choose"){let H=_XA(A.items,A.filter.value),X=Math.max(3,Math.min(12,I-10)),N=Math.max(0,Math.min(A.index-Math.floor(X/2),H.length-X));U="Type to filter · ↑↓ choose · ⏎ pick · Esc cancel",G=d(PB,{children:[R(e,{borderStyle:"single",borderColor:L.border,paddingX:1,children:R(p0,{state:A.filter,width:D-8,placeholder:"Filter…"})}),H.slice(N,N+X).map((z,F)=>{let V=A.items[z],O=N+F===A.index;return d(e,{justifyContent:"space-between",children:[d(f,{color:O?L.focus:L.text,wrap:"truncate-end",children:[O?hA.pointer:" "," ",V.label]}),V.detail?d(f,{color:L.faint,wrap:"truncate-end",children:[" ",V.detail]}):null]},z)}),!H.length?R(f,{color:L.muted,children:"Nothing matches."}):null]})}else if(A.kind==="confirm")U=`y / ⏎ ${A.confirmLabel.toLowerCase()} · n / Esc cancel`,G=A.body?R(f,{color:L.muted,wrap:"wrap",children:A.body}):null;else U="⏎ done",G=d(PB,{children:[R(e,{borderStyle:"single",borderColor:L.highlight,paddingX:1,marginY:1,children:R(f,{color:L.highlight,wrap:"wrap",children:A.secret})}),R(f,{color:L.muted,wrap:"wrap",children:A.note})]});let Y=A.kind==="confirm"&&A.danger;return R(e,{position:"absolute",top:0,left:0,width:E,height:I,alignItems:"center",justifyContent:"center",children:d(e,{flexDirection:"column",width:D,borderStyle:"single",borderColor:Y?L.danger:L.focus,paddingX:2,paddingY:1,backgroundColor:L.panel,children:[R(f,{bold:!0,color:Y?L.danger:L.text,wrap:"wrap",children:A.title}),R(e,{flexDirection:"column",marginTop:1,children:G}),R(e,{marginTop:1,children:R(f,{color:L.faint,children:U})})]})})}var p1;var WXA=W(async()=>{RD();bB();HQ();await $0([dB(),gD()]);p1=pA(JQ(),1)});var jXA=()=>{};var RXA=()=>{};var gXA=()=>{};function TAQ(A){try{return new Intl.NumberFormat("en",{style:"currency",currency:A}).resolvedOptions().maximumFractionDigits??2}catch{return 2}}function aQ(A,Q="CAD"){if(A===void 0||A===null||!/^-?\d+$/.test(A))return"—";let B=TAQ(Q),E=BigInt(A),I=E<0n?-E:E,D=10n**BigInt(B),J=(I/D).toLocaleString("en-CA"),G=B?`.${(I%D).toString().padStart(B,"0")}`:"";return`${E<0n?"−":""}${Q} ${J}${G}`}function oQ(A){if(!A)return"—";let Q=new Date(A.length===10?`${A}T12:00:00Z`:A);return Number.isNaN(Q.valueOf())?"—":new Intl.DateTimeFormat("en-CA",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"}).format(Q)}var iH=W(()=>{jXA();Yh();RXA();gXA();yH();yH()});function Th(A){return typeof A==="string"&&PAQ.includes(A)}function W0(A,Q,B=`${Q}s`){return A===1?Q:B}function TXA(A){return A==="match_payout"?"/finance/reconcile?view=stripe":`/finance/transactions?status=needs_you&ask=${encodeURIComponent(A)}`}var PAQ,MM;var Ph=W(()=>{PAQ=["forward_receipt","review_document","contractor_invoice","choose_contractor","choose_category","confirm_business","confirm_income","confirm_tax","match_payout","approve","import_statement","reimbursement_receipts"];MM={forward_receipt:{label:(A)=>`Find ${A} ${W0(A,"receipt")}`,phrase:(A)=>`${A} ${W0(A,"receipt")} to find`,detail:"Oatmilk searched the inbox and the bank and couldn't find them.",action:"Find receipts"},review_document:{label:(A)=>`Review documents for ${A} ${W0(A,"transaction")}`,phrase:(A)=>`${A} ${W0(A,"transaction")} with documents to review`,detail:"The originals are attached. Their details, business use and tax still need review.",action:"Review documents"},reimbursement_receipts:{label:(A)=>`Add receipts for ${A} ${W0(A,"reimbursement")}`,phrase:(A)=>`${A} ${W0(A,"reimbursement")} needing receipts`,detail:"Add the original purchases and their receipts to support the reimbursement payment.",action:"Add reimbursement receipts"},contractor_invoice:{label:(A)=>`Add ${A} contractor ${W0(A,"invoice")}`,phrase:(A)=>`${A} contractor ${W0(A,"invoice")} to add`,detail:"Contractor payments need the contractor's invoice or your agreement, not a receipt.",action:"Add invoices"},choose_contractor:{label:(A)=>`Identify ${A} contractor ${W0(A,"payment")}`,phrase:(A)=>`${A} contractor ${W0(A,"payment")} to identify`,detail:"Choose who was paid, or mark a payment as unrelated to contractors.",action:"Identify contractors"},choose_category:{label:(A)=>`Choose a category for ${A} ${W0(A,"transaction")}`,phrase:(A)=>`${A} ${W0(A,"category","categories")} to choose`,detail:"Your answer is remembered for the same merchant.",action:"Choose categories"},confirm_business:{label:(A)=>`Check ${A} possible personal ${W0(A,"purchase")}`,phrase:(A)=>`${A} possible personal ${W0(A,"purchase")} to check`,detail:"Confirm whether they were for the business.",action:"Check purchases"},confirm_income:{label:(A)=>`Confirm ${A} incoming ${W0(A,"payment")}`,phrase:(A)=>`${A} incoming ${W0(A,"payment")} to confirm`,detail:"Link the invoice or confirm the income and its tax.",action:"Confirm income"},confirm_tax:{label:(A)=>`Confirm sales tax on ${A} Stripe ${W0(A,"payment")}`,phrase:(A)=>`sales tax on ${A} Stripe ${W0(A,"payment")} to confirm`,detail:"Stripe didn't record the tax for them.",action:"Confirm sales tax"},match_payout:{label:(A)=>`Match ${A} Stripe ${W0(A,"payout")} to deposits`,phrase:(A)=>`${A} Stripe ${W0(A,"payout")} to match`,detail:"Connect or import the account that received them.",action:"Match payouts"},approve:{label:(A)=>`Approve ${A} prepared ${W0(A,"transaction")}`,phrase:(A)=>`${A} prepared ${W0(A,"transaction")} to approve`,detail:"Everything is filled in and waiting for you.",action:"Review and approve"},import_statement:{label:(A)=>`Import card statements for ${A} ${W0(A,"receipt")}`,phrase:(A)=>`card statements to import for ${A} ${W0(A,"receipt")}`,detail:"Their receipts are waiting to be matched to the card's statement.",action:"Import statements"}}});function wAQ(A){return A==="directory"?"/people/contractors":`/people/contractors?view=${A}`}function N$(A,Q){return{label:A,view:Q,href:wAQ(Q)}}function PD(A,Q,B,E,I=!1){return{...N$(A,Q),group:B,description:E,...I?{adminOnly:I}:{}}}function bXA(A){if(!A)return"directory";if(bAQ.has(A))return A;return SAQ[A]??"directory"}var SAQ,PXA,SXA,wXA,vXA,vAQ,nH,bAQ;var kXA=W(()=>{SAQ={people:"directory"};PXA=N$("Contractors","directory"),SXA=N$("Settings","setup"),wXA=[N$("Timesheets","timesheets"),N$("Payouts","payouts"),N$("Tax forms","tax"),N$("Insights","insights")],vXA=[PXA,...wXA,SXA];vAQ=[PD("Reminders and approvals","settings","setup","Who approves hours, when reminders go out, and how payouts are sent.",!0),PD("Job roles","roles","setup","The roles, levels and pay bands you hire for."),PD("Agreement templates","templates","setup","The agreements you send contractors to sign."),PD("Hours form","hours-form","setup","Choose what contractors fill in when they log hours."),PD("Import contractors","import","setup","Add several contractors at once from a spreadsheet."),PD("Documents","documents","records","Invoices and files contractors have sent."),PD("Timesheet history","history","records","Every past timesheet, paid or not."),PD("Email activity","email","records","Which emails were sent to contractors."),PD("Activity log","activity","records","Everything that changed, and who changed it.")],nH=[{...PXA,label:"All contractors"},...wXA,SXA,...vAQ],bAQ=new Set(nH.map((A)=>A.view))});function kAQ(A,Q){if(Q?.you)return"You invited them";if(Q?.name)return`Invited by ${Q.name}`;return A==="team"?"Joined your team":"Joined by invitation"}function xAQ(A){return{id:`join-notice:${A.id}`,label:A.summary,detail:kAQ(A.kind,A.invitedBy),href:A.href,verb:"View"}}function xXA(A){return(A?.items??[]).map(xAQ)}var yXA=()=>{};function fXA(A){return A.items.map((Q)=>({id:`snooze-notice:${Q.itemId}`,label:Q.title,detail:"Your snooze ended. This item needs attention again.",href:`/checklist?item=${encodeURIComponent(Q.itemId)}`,verb:"Review"}))}function wh(A){return vh.find((Q)=>Q.id===A)}function bh(A){let Q=A.get("view");if(Q&&Sh[Q]&&Sh[Q]!=="all")return wh(Sh[Q]);return yAQ.get(A.get("status")??"")??wh("all")}function fAQ(A){let Q=wh(A);if(Q.id==="all")return"/finance/invoices";if(Q.kind==="invoices")return`/finance/invoices?status=${Q.archived?"archived":Q.status}`;return`/finance/invoices?view=${Q.id==="archived_accounts"?"archived-accounts":Q.id}`}function kh(){return{id:"invoices",title:"Invoices",groups:["main","work","closed","accounts"].map((Q)=>({...hXA[Q]?{label:hXA[Q]}:{},links:vh.filter((B)=>B.group===Q).map((B)=>({id:B.id,label:B.label,href:fAQ(B.id),...B.countKey?{countKey:B.countKey}:{}}))}))}}var vh,yAQ,Sh,hXA;var uXA=W(()=>{vh=[{id:"all",label:"All invoices",heading:"Invoices",kind:"invoices",group:"main"},{id:"needs_action",label:"Needs action",heading:"Needs action",kind:"invoices",status:"needs_action",group:"main",countKey:"invoicesNeedAction"},{id:"open",label:"Unpaid",heading:"Unpaid invoices",kind:"invoices",status:"open",group:"main"},{id:"overdue",label:"Overdue",heading:"Overdue invoices",kind:"invoices",status:"overdue",group:"main",countKey:"invoicesOverdue"},{id:"paid",label:"Paid",heading:"Paid invoices",kind:"invoices",status:"paid",group:"main"},{id:"draft",label:"Drafts",heading:"Drafts",kind:"invoices",status:"draft",group:"work",countKey:"invoicesDrafts"},{id:"scheduled",label:"Scheduled",heading:"Scheduled",kind:"scheduled",group:"work"},{id:"uncollectible",label:"Written off",heading:"Written off",kind:"invoices",status:"uncollectible",group:"closed"},{id:"void",label:"Cancelled",heading:"Cancelled invoices",kind:"invoices",status:"void",group:"closed"},{id:"archived",label:"Archived",heading:"Archived invoices",kind:"invoices",archived:"only",group:"closed"},{id:"customers",label:"Customers",heading:"Customers",kind:"accounts",accounts:"customers",group:"accounts"},{id:"vendors",label:"Vendors",heading:"Vendors",kind:"accounts",accounts:"vendors",group:"accounts"},{id:"archived_accounts",label:"Archived",heading:"Archived customers and vendors",kind:"accounts",accounts:"archived",group:"accounts"}],yAQ=new Map(vh.filter((A)=>A.status||A.archived).map((A)=>[A.archived?"archived":A.status,A])),Sh={scheduled:"scheduled",customers:"customers",vendors:"vendors",accounts:"customers","archived-accounts":"archived_accounts",invoices:"all"};hXA={main:void 0,work:void 0,closed:"Closed",accounts:"Customers and vendors"}});function xh(A,Q){let B=mXA.find((E)=>E===A)??"overview";return Q!=="admin"&&lXA.includes(B)?"overview":B}function pXA(A){return cXA[A]}function dXA(A,Q={}){let B=new URLSearchParams(A==="overview"?Q:{view:A,...Q}).toString();return B?`/developers?${B}`:"/developers"}function hAQ(A){return mXA.filter((Q)=>A==="admin"||!lXA.includes(Q))}function iXA(A){let Q=new Set(hAQ(A)),B=(I)=>({id:I,label:cXA[I],href:dXA(I)}),E=(I)=>I.filter((D)=>Q.has(D)).map(B);return{id:"developers",title:"Developers",groups:[{links:E(["overview","keys","webhooks"])},{label:"Monitor",links:E(["usage","requests"])},{label:"Build",links:E(["connect"])}]}}var mXA,cXA,lXA;var yh=W(()=>{mXA=["overview","keys","webhooks","usage","requests","connect"],cXA={overview:"Overview",keys:"API keys",webhooks:"Webhooks",usage:"Usage",requests:"Request log",connect:"AI apps"},lXA=["webhooks"]});function uh(A){return uAQ.find((Q)=>Q===A)??"overview"}function nXA(A){return hh[A]}function mAQ(A,Q={}){let B=new URLSearchParams(A==="overview"?{}:{view:A});for(let[I,D]of Object.entries(Q))B.set(I,D);let E=B.toString();return`/chief-of-staff${E?`?${E}`:""}`}function zG(A,Q=hh[A],B=A,E={}){return{id:B,label:Q,href:mAQ(A,E)}}function mh(A=[]){let Q=A.find((E)=>E.connected),B=A.filter((E)=>!E.connected);return{id:"chiefOfStaff",title:"Chief of Staff",groups:[{links:[zG("overview"),zG("activity")]},{label:"Channels",links:[zG("server",Q?.name??hh.server),...B.map((E)=>zG("server",E.name,`server-${E.guildId}`,{server:E.guildId}))]},{label:"Permissions",links:[zG("people"),zG("tools")]},{label:"Settings",links:[zG("schedules"),zG("settings")]}]}}function aXA(A){let Q=uh(A.get("view")),B=A.get("server");return Q==="server"&&B&&/^\d{17,20}$/.test(B)?`server-${B}`:Q}var fh="/chief-of-staff",uAQ,hh;var oXA=W(()=>{uAQ=["overview","server","people","tools","schedules","activity","settings"],hh={overview:"Overview",server:"Discord server",people:"People and roles",tools:"Tools and access",schedules:"Scheduled posts",activity:"Activity",settings:"General"}});var cAQ,z$="/god-mode",lAQ,pAQ,okQ;var ch=W(()=>{cAQ=["/inbox","/checklist","/calendar","/ai","/compliance","/chief-of-staff","/logs","/history","/developers","/settings"],lAQ=[...cAQ,"/finance","/legal","/people","/insights"],pAQ=["accounting","ops",...lAQ.map((A)=>A.slice(1))],okQ=new RegExp(`^(?:\\/onboarding(?:[?#][^\\s\\\\]*)?|\\/(?:${pAQ.join("|")})(?:[/?#][^\\s\\\\]*)?|\\/(?:[?#][^\\s\\\\]*)?)$`)});function uU(A){return Object.entries(hU).filter(([,E])=>A===E||A.startsWith(`${E}/`)).sort((E,I)=>I[1].length-E[1].length)[0]?.[0]??iAQ[A]??"home"}function VM(A){return nAQ[A]}function sAQ(A){let Q=bXA(A);if(Q==="directory")return;return nH.find((B)=>B.view===Q)?.label}function _M(A){if(A.documentWriter)return"Write an agreement";if(A.agreementComposer)return A.search.get("draft")?"Continue your agreement":"New agreement";return rAQ[A.view]?.(A)??VM(A.view)}function tAQ(A){return A==="admin"||A==="finance"}function sXA(A){if(A==="reconcile")return"transactions";if(A==="calendar")return"checklist";if(A==="tax")return"taxInfo";return A}function AQQ(A){return eAQ.find((Q)=>Q===A)??"overview"}function tXA(){return{id:"godMode",title:"God Mode",groups:[{links:[{id:"overview",label:"Overview",href:z$},{id:"signups",label:"Sign-ups",href:`${z$}?view=signups`},{id:"workspaces",label:"Workspaces",href:`${z$}?view=workspaces`},{id:"experiments",label:"Experiments",href:`${z$}?view=experiments`}]}]}}function AZA(A){return eXA.find((Q)=>Q===A)??"finance"}function QZA(){return{id:"insights",title:"Insights",groups:[{links:eXA.map((A)=>({id:A,label:A[0].toUpperCase()+A.slice(1),href:A==="finance"?"/insights":`/insights?view=${A}`}))}]}}function QQQ(A,Q="company"){let B=BZA.filter((I)=>Q!=="personal"||I.key!=="contractors"),E={id:"uploads",label:SD.uploads,href:"/inbox?view=uploads"};if(A==="contributor")return{id:"inbox",title:"Inbox",groups:[{links:[{id:"mine",label:SD.mine,href:"/inbox"},E,{id:"connected",label:SD.connected,href:"/inbox?view=connected"}]}]};return{id:"inbox",title:"Inbox",groups:[{links:[{id:"receipts",label:SD.receipts,href:"/inbox?view=receipts"},{id:"email",label:SD.email,href:"/inbox?view=email"},...A==="admin"?[{id:"quarantine",label:SD.quarantine,href:"/inbox?view=email&mailStatus=quarantined"}]:[],E]},{label:"Mailboxes",links:B.map((I)=>({id:`mailbox-${I.key}`,label:I.label,href:`/inbox?view=email&mailbox=${I.key}`}))},{label:"Connect",links:[{id:"connected",label:SD.connected,href:"/inbox?view=connected"}]},...A==="admin"||A==="finance"?[{label:"Settings",links:[{id:"ai",label:SD.ai,href:"/inbox?view=ai"}]}]:[]]}}function IZA(A,Q){let B=A.get("view");if(B==="connected")return"connected";if(B==="uploads")return"uploads";if(B==="ai"&&(Q==="admin"||Q==="finance"))return"ai";if(Q==="contributor")return"mine";if(B==="receipts")return"receipts";if(Q==="admin"&&A.get("mailStatus")==="quarantined")return"quarantine";let E=A.get("mailbox");return E&&/^[a-z][a-z0-9_-]{1,39}$/.test(E)?`mailbox-${E}`:"email"}function BQQ(A){return SD[A]??BZA.find((Q)=>`mailbox-${Q.key}`===A)?.label??"Inbox"}function DZA(A,Q,B=!1){let E=IQQ.find((I)=>I===A)??"overview";if(Q==="contributor")return"connections";return Q!=="admin"&&EQQ.includes(E)?"overview":E}function DQQ(A){return EZA[A]}function JZA(A){let Q=A==="admin",B=(I,D)=>({id:I,label:EZA[I],href:I==="overview"?"/ai":`/ai?view=${I}`,...D?{countKey:D}:{}}),E=[B("playground"),...Q?[B("classifiers"),B("memory"),B("settings")]:[]];return{id:"ai",title:"AI",groups:[{links:[B("overview","activeJobs"),B("agents"),B("connections")]},{label:"Advanced",links:E}]}}function JQQ(A){return A&&Object.hasOwn(lh,A)?A:null}function rXA(A="company"){let Q=Object.keys(lh).filter((B)=>B!=="slips"||A!=="personal").map((B)=>({id:B,label:lh[B],href:`/finance/tax?view=${B}`}));return{id:"tax",title:"Taxes",groups:[{links:[{id:"info",label:"Tax info",href:"/finance/tax/info"},{id:"prep",label:"Year-end",href:"/finance/tax"},{id:"stripe",label:"Stripe for the year",href:"/finance/tax?view=stripe"},{id:"records",label:"Records",href:"/finance/tax?view=records"}]},{label:"File it yourself",links:Q},{label:"Company",links:[{id:"shareholders",label:"Shareholders",href:"/finance/tax?view=shareholders"}]}]}}function CZA(A){return GZA.find((Q)=>Q===A)??"ask"}function CQQ(A){return A==="ask"?"":A==="library"?"Compliance library":A==="items"?"Open items":"Compliance research"}function ph(A,Q){if(A!=="admin"&&A!=="finance")return[];return GZA.filter((B)=>B==="ask"||B==="library"||B==="items"&&A==="admin"||B==="research"&&A==="admin"&&Q)}function $ZA(A,Q){let B=ph(A,Q),E=(D)=>({id:D,label:GQQ[D],href:D==="ask"?"/compliance":`/compliance?view=${D}`});return{id:"compliance",title:"Compliance",groups:[{links:B.filter((D)=>D!=="research").map(E)},...B.includes("research")?[{label:"Platform",links:[E("research")]}]:[]]}}function YZA(A,Q){let B=$QQ.find((E)=>E===A)??"postings";if(Q==="contributor"&&B==="board")return"postings";return B}function UQQ(A){return UZA[A]}function KZA(A){let Q=A!=="contributor",B=(E)=>({id:E,label:UZA[E],href:E==="postings"?"/people/recruiting":`/people/recruiting?view=${E}`});return{id:"people",title:"People",groups:[{label:"Recruiting",links:[B("postings"),B("interviews"),...Q?[B("board")]:[]]},...Q?[{label:"Team",links:[{id:"contractors",label:"Contractors",href:"/people/contractors"},{id:"roles",label:"Job roles",href:"/people/contractors?view=roles"},{id:"timesheets",label:"Timesheets",href:"/people/contractors?view=timesheets"}]}]:[]]}}function ZZA(A){return HZA.find((Q)=>Q===A)??(A?YQQ[A]:void 0)??"all"}function KQQ(A){return XZA[A]}function HQQ(A){return A==="all"?"/legal/agreements":`/legal/agreements?view=${A}`}function XQQ(A="company"){return HZA.filter((Q)=>A!=="personal"||Q!=="contracts"&&Q!=="jobs")}function NZA(A="company"){let Q=(B)=>({id:B,label:XZA[B],href:HQQ(B)});return{id:"documents",title:"Agreements",groups:[{links:XQQ(A).map(Q)}]}}function zZA(A,Q="company"){return Q!=="personal"||!ZQQ.has(A)}function qZA(A,Q){return Q&&(A==="admin"||A==="finance")}function E1(A,Q,B=!1,E="company"){if(!zZA(A,E))return null;if(A==="chiefOfStaff")return qZA(Q,B)?mh():null;if(A==="insights"&&Q!=="contributor")return QZA();if(A==="godMode")return Q==="admin"&&B?tXA():null;if(A==="people")return KZA(Q);if(A==="ai"&&Q!=="contributor")return JZA(Q);if(A==="developers")return iXA(Q);if(A==="compliance")return ph(Q,B).length?$ZA(Q,B):null;if(A==="inbox")return QQQ(Q,E);if(A==="taxInfo"&&Q!=="contributor")return rXA(E);if(A==="tax"&&Q!=="contributor")return rXA(E);if(A==="documents"&&Q!=="contributor")return NZA(E);if(A==="invoices"&&Q!=="contributor")return kh();if(A!=="transactions"&&A!=="reconcile")return null;let I=Q!=="contributor",D=Q==="admin"||Q==="finance";return{id:"transactions",title:"Transactions",groups:[{links:[{id:"all",label:"All transactions",href:"/finance/transactions"},{id:"needs_you",label:"Needs you",href:"/finance/transactions?status=needs_you",countKey:"needsYou"},{id:"working",label:"AI working",href:"/finance/transactions?status=working",countKey:"working"},{id:"done",label:"Done",href:"/finance/transactions?status=reviewed"}]},...I?[{links:[{id:"projects",label:"Projects",href:"/finance/transactions?view=projects"},...D?[{id:"merchants",label:"Merchants",href:"/finance/transactions?view=merchants"},{id:"trips",label:"Trips",href:"/finance/transactions?view=trips"}]:[]]},{label:"Reconcile",links:[{id:"matching",label:"Receipt matching",href:"/finance/reconcile?view=matching",countKey:"matching"},{id:"stripe",label:"Stripe payouts",href:"/finance/reconcile?view=stripe",countKey:"stripe"},{id:"bank",label:"Bank transactions",href:"/finance/reconcile?view=bank"}]},{label:"Accounts",links:[{id:"accounts",label:"Accounts and imports",href:"/finance/transactions?view=accounts"},...D?[{id:"statements",label:"Statements",href:"/finance/transactions?view=statements"}]:[]]}]:[]]}}function NQQ(A,Q,B="admin"){if(A==="chiefOfStaff")return aXA(Q);if(A==="insights")return AZA(Q.get("view"));if(A==="godMode")return AQQ(Q.get("view"));if(A==="ai")return DZA(Q.get("view"),B);if(A==="developers")return xh(Q.get("view"),B);if(A==="compliance")return CZA(Q.get("view"));if(A==="inbox")return IZA(Q,B);if(A==="taxInfo")return"info";if(A==="tax")return Q.get("view")==="records"?"records":Q.get("view")==="stripe"?"stripe":Q.get("view")==="shareholders"?"shareholders":JQQ(Q.get("view"))??"prep";if(A==="people")return YZA(Q.get("view"),B);if(A==="documents")return ZZA(Q.get("view"));if(A==="invoices")return bh(Q).id;if(A==="reconcile")return["stripe","bank"].includes(Q.get("view")??"")?Q.get("view"):"matching";if(Q.get("view")==="accounts")return"accounts";if(Q.get("view")==="projects")return"projects";if(Q.get("view")==="merchants")return"merchants";if(Q.get("view")==="trips")return"trips";if(Q.get("view")==="statements")return"statements";let E=Q.get("status");return E==="needs_you"?"needs_you":E==="working"?"working":E==="reviewed"?"done":"all"}function q$(A,Q=!1,B="company"){return zQQ(A,Q,B).filter((E)=>zZA(E.id,B))}function zQQ(A,Q,B){let E=A!=="contributor",I=(J,G)=>tAQ(A)?[{id:J,area:G,label:"AI",href:hU[J],children:[]}]:[],D=(J,G)=>J.groups.flatMap((U)=>U.links).filter((U)=>U.id!==G).map((U)=>({label:U.label,href:U.href,view:U.id}));return[{id:"home",area:"ops",label:"Home",href:"/",children:[]},{id:"inbox",area:"ops",label:"Inbox",href:"/inbox",children:[...E?[{label:"Email",href:"/inbox?view=email",view:"email"},{label:"Receipts",href:"/inbox?view=receipts",view:"receipts"}]:[{label:"My receipts",href:"/inbox",view:"receipts"}],{label:"Connected inboxes",href:"/inbox?view=connected",view:"connected"}]},...E?[{id:"checklist",area:"ops",label:"Checklist",href:"/checklist",children:[{label:"Calendar",href:"/calendar",view:"calendar"}]},{id:"ai",area:"ops",label:"Autopilot",href:"/ai",children:D(JZA(A),"overview")},...ph(A,Q).length?[{id:"compliance",area:"ops",label:"Compliance",href:"/compliance",children:D($ZA(A,Q),"ask")}]:[],...qZA(A,Q)?[{id:"chiefOfStaff",area:"ops",label:"Chief of Staff",href:fh,children:D(mh(),"overview")}]:[]]:[],...A==="admin"?[{id:"logs",area:"ops",label:"Logs",href:"/logs",children:[]}]:[],...A==="accountant"?[]:[{id:"developers",area:"ops",label:"Developers",href:"/developers",children:[]}],...A==="admin"&&Q?[{id:"godMode",area:"ops",label:"God Mode",href:z$,children:D(tXA(),"overview")}]:[],...I("financeAi","finance"),{id:"transactions",area:"finance",label:"Transactions",href:"/finance/transactions",children:[{label:"Needs you",href:"/finance/transactions?status=needs_you",view:"needs_you"},...E?[{label:"Projects",href:"/finance/transactions?view=projects",view:"projects"},...A==="admin"||A==="finance"?[{label:"Merchants",href:"/finance/transactions?view=merchants",view:"merchants"},{label:"Trips",href:"/finance/transactions?view=trips",view:"trips"}]:[],{label:"Receipt matching",href:"/finance/reconcile?view=matching",view:"matching"},{label:"Stripe payouts",href:"/finance/reconcile?view=stripe",view:"stripe"},{label:"Bank transactions",href:"/finance/reconcile?view=bank",view:"bank"},{label:"Accounts and imports",href:"/finance/transactions?view=accounts",view:"accounts"},...A==="admin"||A==="finance"?[{label:"Statements",href:"/finance/transactions?view=statements",view:"statements"}]:[]]:[]]},...A==="accountant"?[]:[{id:"reimbursements",area:"finance",label:"Reimbursements",href:hU.reimbursements,children:[]}],...E?[{id:"invoices",area:"finance",label:"Invoices",href:"/finance/invoices",children:D(kh(),"all")},{id:"financialStatements",area:"finance",label:"Financial statements",href:hU.financialStatements,children:[]},{id:"taxInfo",area:"finance",label:"Taxes",href:"/finance/tax/info",children:[]},...A==="admin"||A==="finance"?[{id:"budgets",area:"finance",label:"Budgets",href:hU.budgets,children:[{label:"Spending",href:"/finance/budgets?part=spending",view:"spending"},{label:"Reserves",href:"/finance/budgets?part=reserves",view:"reserves"}]}]:[],{id:"reports",area:"finance",label:"Reports",href:"/finance/reports",children:[]},...A==="admin"||A==="finance"?[{id:"subscriptions",area:"finance",label:"Subscriptions",href:hU.subscriptions,children:[]}]:[],...I("insightsAi","insights"),{id:"insights",area:"insights",label:"Insights",href:"/insights",children:D(QZA(),"finance")},...I("legalAi","legal"),{id:"documents",area:"legal",label:"Agreements",href:"/legal/agreements",children:D(NZA(B))},...I("peopleAi","people"),{id:"people",area:"people",label:"Recruiting",href:"/people/recruiting",children:D(KZA(A))},{id:"contractors",area:"people",label:"Contractors",href:"/people/contractors",children:vXA}]:[{id:"people",area:"people",label:"Interviews",href:"/people/recruiting?view=interviews",children:[]}],...A==="admin"||A==="finance"?[{id:"history",area:"ops",label:"History",href:"/history",children:[]}]:[],{id:"settings",area:"ops",label:"Settings",href:"/settings",children:[]}]}function MZA(A,Q=!1,B="company"){let E=q$(A,Q,B).filter((I)=>I.id!=="settings"&&I.id!=="history");return dAQ.map((I)=>({...I,destinations:E.filter((D)=>D.area===I.id)})).filter((I)=>I.destinations.length>0)}function qQQ(A,Q,B){let E=A==="choose_category"&&B&&B<Q?`From ${B} ${B===1?"merchant":"merchants"}. One answer settles each merchant's other transactions.`:MM[A].detail;return{id:`ask-${A}`,label:MM[A].label(Q),detail:E,href:TXA(A),verb:MM[A].action}}function FQQ(A,Q){let B=Q.length===1?`card ending ${Q[0]}`:Q.length?`cards ending ${Q.slice(0,-1).join(", ")} and ${Q.at(-1)}`:"card";return{id:"card-receipts",label:`Find ${A} ${A===1?"receipt":"receipts"} for your ${Q.length>1?"cards":"card"}`,detail:`Purchases on your ${B}`,href:"/",verb:"Add receipts"}}function VQQ(A){return{id:"accountant-questions",label:`Your accountant asked ${A} ${A===1?"question":"questions"}`,detail:"Answer them so they can finish your books.",href:"/settings?section=people&questions=open",verb:"Answer"}}function _QQ(A){return{id:"accountant-changes",label:`Your accountant asked for ${A} ${A===1?"change":"changes"}`,detail:"Approve or decline each one. Nothing changes until you approve.",href:"/settings?section=people",verb:"Review"}}function OQQ(A,Q){let B=[...A!=="accountant"?[{label:"Your requests",reads:[MQQ],items:([E])=>{let I=E.total??0;return I>0?[{id:"personal-requests",label:`${I} ${I===1?"request needs":"requests need"} you`,detail:"People on your team are waiting for your help.",href:"/?requests=mine",verb:"Review"}]:[]}}]:[],{label:"Receipt processing",reads:[{action:"inbox.list",input:{status:"failed",limit:5}}],items:([E])=>{let I=E;return I.items.length?[{id:"receipt-failures",label:"Review failed receipts",detail:`${I.items.length}${I.nextCursor?"+":""} failed submissions`,href:"/inbox?view=receipts",verb:"Review"}]:[]}},{label:"Receipt review",reads:[{action:"inbox.list",input:{status:"review",limit:5}}],items:([E])=>{let I=E;return I.items.length?[{id:"receipt-review",label:A==="contributor"?"Check your receipts":"Review receipts",detail:`${I.items.length}${I.nextCursor?"+":""} submissions`,href:"/inbox?view=receipts",verb:"Review"}]:[]}},{label:"Your cards",reads:[{action:"attention.mine",input:{limit:5}}],items:([E])=>{let I=E;return I.total?[FQQ(I.total,I.cards)]:[]}}];if(A==="contributor")return B;if(B.unshift({label:"Autopilot",reads:[{action:"attention.list",input:{limit:1}}],items:([E])=>{let I=E,D=I.groups.filter((J)=>J.count>0&&Th(J.kind)).map((J)=>qQQ(J.kind,J.count,J.merchants));if(I.contractorQuestions?.total)D.push({id:"contractor-payment-questions",label:`Identify ${I.contractorQuestions.total} historical contractor ${I.contractorQuestions.total===1?"payment":"payments"}`,detail:"Choose who was paid, or mark the transfer as unrelated to contractors.",href:"/",verb:"Identify"});for(let J of I.timesheetPayments?.items??[])D.push({id:`timesheet-payment-${J.id}`,label:J.title,detail:J.detail,href:"/",verb:"Review"});return D}}),Q)B.push({label:"Your checklist",reads:[{action:"compliance.items.list",input:{status:"open",assigneeUserId:Q,limit:3}}],items:([E])=>E.items.filter((I)=>!["done","skipped"].includes(I.status)).map((I)=>({id:`assigned-${I.id}`,label:I.title,detail:"Assigned to you",href:`/checklist?item=${I.id}`}))});if(B.push({label:"Wise setup",reads:[{action:"wise.status",input:{}}],items:([E])=>{return E.ready?[]:[{id:"wise-setup",label:A==="admin"?"Set up Wise":"Wise setup needs an admin",detail:A==="admin"?"Connect and sync history":"Ask an administrator to connect it",href:A==="admin"?"/settings?section=connections":"/finance/transactions",verb:A==="admin"?"Set up":"Open"}]}},...A==="admin"||A==="finance"?[{label:"Accountant questions",reads:[{action:"accountants.comments.list",input:{status:"active",limit:5}}],items:([E])=>{let I=E.openTotal??0,D=A==="admin"?E.pendingChanges??0:0;return[...I>0?[VQQ(I)]:[],...D>0?[_QQ(D)]:[]]}}]:[],{label:"Compliance deadlines",reads:[{action:"compliance.checklist",input:{includeDone:!1}}],items:([E])=>{let I=E,D=I.summary?.overdue??0,J=I.summary?.dueSoon??0;if(!D&&!J)return[];return[{id:"compliance-deadlines",label:D?"Review overdue deadlines":"Review upcoming deadlines",detail:[D?`${D} overdue`:null,J?`${J} due within 14 days`:null].filter(Boolean).join(" · "),href:"/checklist",verb:"Review"}]}}),B.push({label:"New people",reads:[{action:"notifications.joins.list",input:{}}],items:([E])=>xXA(E)}),B.push({label:"Snoozed items",reads:[{action:"notifications.checklist.list",input:{}}],items:([E])=>fXA(E)}),A==="admin"||A==="finance")B.push({label:"Document comments",reads:[{action:"notifications.comments.list",input:{}}],items:([E])=>E.items.map((I)=>({id:`doc-comment-${I.id}`,label:I.label,detail:I.detail,href:I.href,verb:"Review"}))});return B}function VZA(A,Q){let B=LQQ[A]??[];return OQQ(A,Q).filter((E)=>!B.includes(E.label))}function _ZA(A,Q){let B=0,E=[],I=[],D=[];for(let J of A){let G=Q.slice(B,B+J.reads.length);if(B+=J.reads.length,G.length<J.reads.length||G.some((U)=>U.status==="loading")){D.push(J.label);continue}if(G.some((U)=>U.status==="failed")){I.push(J.label);continue}try{if(E.push(...J.items(G.map((U)=>U.data))),G.some((U)=>U.status==="stale"))I.push(J.label)}catch{I.push(J.label)}}return{items:E,unavailable:I,loading:D}}var dAQ,hU,iAQ,nAQ,aAQ,oAQ,rAQ,eAQ,eXA,BZA,SD,IQQ,EQQ,EZA,lh,GZA,GQQ,$QQ,UZA,HZA,XZA,YQQ,ZQQ,FZA="/legal/agreements/write",MQQ,LQQ;var mU=W(()=>{iH();Ph();kXA();yXA();uXA();yh();oXA();ch();dAQ=[{id:"ops",label:"Ops"},{id:"finance",label:"Finance"},{id:"legal",label:"Legal"},{id:"people",label:"People"},{id:"insights",label:"Insights"}],hU={home:"/",chiefOfStaff:fh,inbox:"/inbox",checklist:"/checklist",calendar:"/calendar",ai:"/ai",financeAi:"/finance/ai",peopleAi:"/people/ai",legalAi:"/legal/ai",insightsAi:"/insights/ai",compliance:"/compliance",logs:"/logs",history:"/history",developers:"/developers",godMode:z$,settings:"/settings",transactions:"/finance/transactions",reconcile:"/finance/reconcile",invoices:"/finance/invoices",tax:"/finance/tax",financialStatements:"/finance/financial-statements",taxInfo:"/finance/tax/info",reports:"/finance/reports",insights:"/insights",reimbursements:"/finance/reimbursements",subscriptions:"/finance/subscriptions",budgets:"/finance/budgets",documents:"/legal/agreements",people:"/people/recruiting",contractors:"/people/contractors"},iAQ={"/finance":"transactions","/legal":"documents","/people":"people"};nAQ={home:"Home",chiefOfStaff:"Chief of Staff",inbox:"Inbox",checklist:"Checklist",calendar:"Calendar",invoices:"Invoices",documents:"Agreements",transactions:"Transactions",reconcile:"Reconcile",reports:"Reports",insights:"Insights",reimbursements:"Reimbursements",subscriptions:"Subscriptions",budgets:"Budgets",contractors:"Contractors",people:"People",tax:"Tax preparation",taxInfo:"Tax info",financialStatements:"Financial statements",ai:"Autopilot",financeAi:"Finance AI",peopleAi:"People AI",legalAi:"Legal AI",insightsAi:"Insights AI",compliance:"Compliance",logs:"Logs",history:"History",developers:"Developers",godMode:"God Mode",settings:"Settings"};aAQ={matching:"Receipt matching",stripe:"Stripe payouts",bank:"Bank transactions"},oAQ={accounts:"Accounts and imports",projects:"Projects",merchants:"Merchants",trips:"Trips",statements:"Statements"},rAQ={reconcile:({search:A})=>aAQ[NQQ("reconcile",A)],transactions:({search:A})=>oAQ[A.get("view")??""],ai:({search:A,role:Q,platformOwner:B})=>Q?DQQ(DZA(A.get("view"),Q,B===!0)):void 0,compliance:({search:A})=>CQQ(CZA(A.get("view"))),chiefOfStaff:({search:A})=>{let Q=uh(A.get("view"));return Q==="overview"?void 0:`Chief of Staff · ${nXA(Q)}`},developers:({search:A,role:Q})=>Q?pXA(xh(A.get("view"),Q)):void 0,inbox:({search:A,role:Q})=>Q?BQQ(IZA(A,Q)):void 0,tax:({search:A})=>A.get("view")==="records"?"Tax records":A.get("view")==="workpaper"?"Detailed workpaper":A.get("view")==="stripe"?"Stripe for the year":A.get("view")==="shareholders"?"Shareholders":void 0,documents:({search:A})=>{if(A.get("envelope"))return"";let Q=ZZA(A.get("view"));return Q==="all"?void 0:KQQ(Q)},people:({search:A,role:Q})=>Q?UQQ(YZA(A.get("view"),Q)):void 0,contractors:({search:A})=>sAQ(A.get("view")),invoices:({search:A})=>bh(A).heading,insights:({search:A})=>{let Q=AZA(A.get("view"));return`Insights · ${Q[0].toUpperCase()}${Q.slice(1)}`}};eAQ=["overview","signups","workspaces","experiments"];eXA=["finance","people","projects","tax","map"];BZA=[{key:"accounting",label:"Accounting"},{key:"invoices",label:"Invoices"},{key:"signatures",label:"Signatures"},{key:"contractors",label:"Contractors"},{key:"reminders",label:"Reminders"},{key:"notifications",label:"Notifications"}],SD={receipts:"Receipts and invoices",email:"All email",quarantine:"Quarantine",connected:"Connected inboxes",mine:"My receipts",uploads:"Uploads",ai:"AI settings"};IQQ=["overview","agents","classifiers","playground","memory","connections","settings"],EQQ=["classifiers","memory","settings"],EZA={overview:"Overview",classifiers:"Classifiers",playground:"Try it",memory:"Memory",agents:"Agents",connections:"Connections",settings:"AI settings"};lh={"gst-hst":"GST/HST return",slips:"Contractor slips (T4A)",t2:"Corporate tax (T2)"};GZA=["ask","library","items","research"],GQQ={ask:"Ask",library:"Library",items:"Open items",research:"Research"};$QQ=["postings","interviews","board"],UZA={postings:"Job postings",interviews:"My interviews",board:"Job board"};HZA=["all","contracts","jobs","templates"],XZA={all:"All agreements",contracts:"Contracts",jobs:"Jobs",templates:"Templates"},YQQ={contractors:"contracts"};ZQQ=new Set(["people","contractors","peopleAi"]);MQQ={action:"requests.list",input:{mine:!0,status:"open",limit:50}};LQQ={admin:["Receipt review","Snoozed items"],finance:["Receipt review","Wise setup","Snoozed items"],contributor:[]}});function F$(A){let Q=new URL(A,"https://oatmilk.invalid"),B=Q.pathname.length>1?Q.pathname.replace(/\/+$/,""):Q.pathname;return{href:`${B}${Q.search}`,path:B,params:Q.searchParams}}function LZA(A){return OD(A.href)??""}function cU(A,Q){return Q.startsWith("/cli/")?A:`${A}${Q}`}function jQQ(A){if(A==="/ops")return"/";return A.startsWith("/ops/")?A.slice(4):A}function WZA(A,Q){let{params:B}=A,E=jQQ(A.path),I=B.get("view");if(E===D1)return{kind:"actions"};if(E===WQQ)return{kind:"chat"};if(E==="/")return{kind:"home"};if(E==="/inbox"){if(I==="connected")return{kind:"page"};if(Q==="contributor"||I==="receipts"||I==="uploads")return{kind:"list",list:I==="uploads"?"uploads":"receipts",recordId:B.get("submission")??void 0};return{kind:"list",list:"email",recordId:B.get("mail")??void 0}}if(E==="/checklist")return{kind:"list",list:"checklist",recordId:B.get("item")??void 0};if(E==="/settings")return{kind:"settings"};if(E==="/finance"||E==="/finance/transactions"){if(I==="accounts")return{kind:"list",list:"accounts"};if(I==="merchants"||I==="trips"||I==="statements"){if(!OZA(Q))return{kind:"page"};let J=I==="merchants"?"merchant":I==="trips"?"trip":"statement";return{kind:"list",list:I,recordId:B.get(J)??void 0}}if(I&&I!=="all")return{kind:"page"};return{kind:"list",list:"transactions",recordId:B.get("entry")??void 0}}if(E==="/finance/reconcile"){if(I==="bank")return{kind:"list",list:"bank"};if(I==="stripe")return{kind:"list",list:"stripe"};return{kind:"list",list:"matching"}}if(E==="/finance/invoices")return I==="scheduled"||I==="accounts"?{kind:"page"}:{kind:"list",list:"invoices",recordId:B.get("invoice")??void 0};if(E==="/finance/reimbursements")return{kind:"list",list:"reimbursements"};if(E==="/finance/subscriptions")return{kind:"list",list:"subscriptions"};if(E==="/finance/reports")return{kind:"report"};if(E==="/finance/tax")return I==="records"?{kind:"page"}:{kind:"tax"};if(E==="/insights")return!I||I==="finance"?{kind:"insights"}:{kind:"page"};if(E==="/legal"||E==="/legal/agreements")return I==="templates"?{kind:"page"}:{kind:"list",list:"agreements"};let D=/^\/legal\/agreements\/([0-9a-f-]{36})$/i.exec(E);if(D)return{kind:"list",list:"agreements",recordId:D[1]};if(E==="/history")return OZA(Q)?{kind:"list",list:"history",recordId:B.get("event")??void 0}:{kind:"page"};if(E==="/compliance")return I==="items"&&Q==="admin"?{kind:"list",list:"compliance-items"}:{kind:"page"};if(E==="/developers")return I==="webhooks"&&Q==="admin"?{kind:"list",list:"webhooks"}:{kind:"page"};if(E==="/people"||E==="/people/recruiting")return I==="interviews"||I==="board"?{kind:"page"}:{kind:"list",list:"postings"};if(E==="/people/contractors"){if(I==="timesheets")return{kind:"list",list:"timesheets"};if(!I||I==="directory")return{kind:"list",list:"contractors",recordId:B.get("contractor")??void 0};return{kind:"page"}}return{kind:"page"}}var D1="/cli/actions",WQQ="/cli/chat",OZA=(A)=>A==="admin"||A==="finance";var qG=W(()=>{l1()});function jZA(){let{identity:A,route:Q,layout:B,session:E,role:I,update:D,askAi:J}=FB(),G=uU(Q.path),U=Q.path===D1?"Run an action":_M({view:G,search:Q.params,role:I})||"Oatmilk",Y=A.workspaceKind==="personal"?"Personal":A.organizationName??"Your company",H=B.columns>=100?"⌃K jump ⌃O chat ? keys":"⌃K ?";return d(e,{width:B.columns,height:1,overflow:"hidden",paddingX:1,children:[R(e,{flexGrow:1,flexShrink:1,overflow:"hidden",children:d(f,{wrap:"truncate-end",children:[d(f,{color:L.accent,bold:!0,children:[hA.brand," oatmilk"]}),R(f,{color:L.faint,children:" │ "}),R(f,{color:L.text,bold:!0,children:U}),R(f,{color:L.faint,children:" │ "}),R(f,{color:L.text,children:Y}),d(f,{color:L.muted,children:[" · ",I]}),E.host!=="https://app.getoatmilk.com"?d(f,{color:L.warning,children:[" · ",TI(E.host)]}):null,J.kind==="local"?d(f,{color:L.muted,children:[" · ",R(f,{color:L.accent,children:hA.ai})," ",J.model]}):null]})}),d(e,{flexShrink:0,marginLeft:2,children:[D?d(f,{color:D.state==="available"?L.accent:L.muted,children:[D.state==="available"?`${hA.update} ${D.offer.latest.version} ⌃U`:D.state==="installing"?`Updating to ${D.offer.latest.version}…`:`Restart for ${D.offer.latest.version}`," "]}):null,R(f,{color:L.faint,children:H})]})]})}var RZA=W(async()=>{mU();F1();qG();BE();bB();HQ();await dB()});function lU(A,Q=Date.now()){let B=Math.round((Q-Date.parse(A))/60000);if(!Number.isFinite(B)||B<1)return"just now";if(B<60)return`${B} min ago`;let E=Math.round(B/60);if(E<24)return`${E} h ago`;let I=Math.round(E/24);return I===1?"yesterday":`${I} days ago`}function RQQ(A,Q){let B=[...A.replace(/\s+/g," ")];if(Q<=0)return"";return B.length<=Q?B.join(""):`${B.slice(0,Math.max(0,Q-1)).join("")}…`}function uI(A,Q,B="left"){let E=RQQ(A,Q),I=[...E].length,D=" ".repeat(Math.max(0,Q-I));return B==="right"?`${D}${E}`:`${E}${D}`}var d1=W(()=>{iH()});function zE({rows:A=6,width:Q,columns:B,label:E}){let{frame:I}=x1({interval:120}),D=I%(A+6);return R(e,{flexDirection:"column","aria-label":E,children:Array.from({length:A},(J,G)=>{let U=Math.abs(G-D+3)<=1?L.border:L.skeleton;if(B?.length)return R(f,{color:U,children:B.map((Y,H)=>`${"▆".repeat(Math.max(2,Math.round(Y*(H===1?OM[(G+H)%OM.length]+0.3:0.8))))}`.padEnd(Y+2)).join("")},G);return R(f,{color:U,children:"▆".repeat(Math.max(4,Math.floor(Q*OM[G%OM.length])))},G)})})}var OM;var FG=W(async()=>{bB();HQ();await dB();OM=[0.62,0.48,0.71,0.55,0.66,0.41,0.58,0.69]});function gZA({width:A,height:Q,onClose:B}){iQ((I,D)=>{if(D.escape||D.return||I==="?"||I==="q")B()});let E=Math.min(84,A-4);return R(e,{position:"absolute",top:0,left:0,width:A,height:Q,alignItems:"center",justifyContent:"center",children:d(e,{flexDirection:"column",width:E,borderStyle:"single",borderColor:L.focus,paddingX:2,paddingY:1,backgroundColor:L.panel,children:[R(f,{bold:!0,children:"Keys"}),gQQ.slice(0,Math.max(4,Q-6)).map(([I,D])=>D?d(f,{wrap:"truncate-end",children:[R(f,{color:L.accent,children:I.padEnd(34)}),R(f,{color:L.muted,children:D})]},I):R(f,{color:L.faint,bold:!0,children:I.toUpperCase()},I)),R(f,{color:L.faint,children:"Esc to close · docs: getoatmilk.com/docs/terminal"})]})})}function dh({title:A,width:Q,height:B,items:E,loading:I,error:D,render:J,onPick:G,onClose:U,empty:Y}){let[H,X]=J1.useState(0);iQ((V,O)=>{if(O.escape)U();else if(O.upArrow||V==="k")X((j)=>Math.max(0,j-1));else if(O.downArrow||V==="j")X((j)=>Math.min(E.length-1,j+1));else if(O.return&&E[H])G(E[H])});let N=Math.min(80,Q-4),z=Math.max(3,B-8),F=Math.max(0,Math.min(H-Math.floor(z/2),E.length-z));return R(e,{position:"absolute",top:0,left:0,width:Q,height:B,alignItems:"center",justifyContent:"center",children:d(e,{flexDirection:"column",width:N,borderStyle:"single",borderColor:L.focus,paddingX:2,paddingY:1,backgroundColor:L.panel,children:[R(f,{bold:!0,children:A}),I?R(zE,{rows:3,width:N-8,label:A}):D?R(f,{color:L.danger,children:D}):!E.length?R(f,{color:L.muted,children:Y}):E.slice(F,F+z).map((V,O)=>{let[j,b]=J(V),x=F+O===H;return d(e,{justifyContent:"space-between",children:[d(f,{color:x?L.focus:L.text,wrap:"truncate-end",children:[x?hA.pointer:" "," ",j]}),d(f,{color:L.faint,children:[" ",b]})]},F+O)}),R(f,{color:L.faint,children:"↑↓ choose · ⏎ open · Esc close"})]})})}function TZA({width:A,height:Q,onClose:B}){let E=FB(),[I,D]=J1.useState([]),[J,G]=J1.useState({loading:!0,error:null});return J1.useEffect(()=>{UG(E.session).then((U)=>{D(U),G({loading:!1,error:null})},(U)=>G({loading:!1,error:CQ(U)}))},[E.session]),R(dh,{title:"Recent chats",width:A,height:Q,items:I,loading:J.loading,error:J.error,empty:"No earlier chats yet.",render:(U)=>[U.title,lU(U.updatedAt)],onClose:B,onPick:(U)=>{B(),E.chat.start(U.sessionId),E.setChatVisible(!0),E.setFocus("composer")}})}function PZA({width:A,height:Q,onClose:B}){let E=FB(),I=E.session.kind==="api_key",[D,J]=J1.useState(E.organizations),[G,U]=J1.useState({loading:!I&&!E.organizations.length,error:null}),Y=I?{loading:!1,error:"An API key belongs to one workspace. Sign in with your browser to switch."}:G;J1.useEffect(()=>{if(I)return;PC(E.session).then((N)=>{J(N),U({loading:!1,error:null})},(N)=>U({loading:!1,error:CQ(N)}))},[E.session,I]);let H=TQQ(D,I);async function X(N){if(B(),N.organizationId){await E.switchOrganization(N.organizationId);return}try{let z=await OK(E.session);await E.switchOrganization(z.organizationId)}catch(z){E.toast(CQ(z),"danger")}}return R(dh,{title:"Switch workspace",width:A,height:Q,items:H,loading:Y.loading,error:Y.error,empty:"You can open only this workspace.",render:(N)=>[`${N.organizationId&&N.organizationId===E.identity.organizationId?"● ":""}${Jz(N)}`,N.organizationId?N.kind==="personal"?"just you":N.role:"set up"],onClose:B,onPick:(N)=>void X(N)})}function TQQ(A,Q){let B=A.filter((D)=>D.kind==="personal"),E=A.filter((D)=>D.kind!=="personal").sort((D,J)=>D.name.localeCompare(J.name)),I=!B.length&&!Q&&A.length?[{organizationId:"",name:"Personal",role:"",current:!1,kind:"personal"}]:[];return[...B,...I,...E]}function SZA({width:A,height:Q,onClose:B}){let E=FB(),[I,D]=J1.useState([]),[J,G]=J1.useState({loading:!0,error:null});J1.useEffect(()=>{p4().then((Y)=>{D(_z(Y)),G({loading:!1,error:null})},(Y)=>G({loading:!1,error:CQ(Y)}))},[]);let U=!J.loading&&I.length===1;return R(dh,{title:U?"Ask AI uses Oatmilk's AI. Start Ollama or LM Studio to use a model here.":"Where should Ask AI think?",width:A,height:Q,items:I,loading:J.loading,error:J.error,empty:"",render:(Y)=>[`${Av(Y.choice,E.askAi)?`${hA.done} `:""}${Y.label}`,Y.detail],onClose:B,onPick:(Y)=>{if(B(),!Av(Y.choice,E.askAi))E.setAskAi(Y.choice).catch((H)=>E.toast(CQ(H),"danger"))}})}var J1,gQQ;var wZA=W(async()=>{PU();wQ();d1();SC();fJ();xJ();BE();bB();HQ();await $0([dB(),FG()]);J1=pA(JQ(),1),gQQ=[["Everywhere",""],["⌃K","Jump to a page, find a record, run an action"],["⌃O","Show or hide Ask AI"],["⌃G","Open the page Ask AI offered"],["Tab / ⇧Tab","Move between the sidebar, the page and the message box"],["/theme","Change the theme (it follows your terminal's light or dark)"],["/model","Where Ask AI thinks: Oatmilk, or a model on this computer"],["⌃U or /update","Update oatmilk when a new version is out"],["⌃C twice","Quit"],["Lists",""],["↑↓ j k · PgUp PgDn · g G","Move"],["⏎ or →","Open the record beside the list"],["Esc or ←","Close it, or go back to the sidebar"],["/","Search this list"],["[ ]","Previous or next view (Needs you, Done…)"],["i","Ask AI about the highlighted record"],["o · y","Open in the browser · copy its link"],["R","Refresh"],["Letters","The record's actions, shown at the bottom (a approve, c categorize…)"],["Message box",""],["⏎","Send · ⌥⏎ or ⌃J for a new line"],["↑ ↓","Earlier messages, or the answers to Ask AI's question"],["PgUp PgDn","Scroll the chat"],["/new /chats /org /run /go /logout","Commands"],["Esc","Stop Ask AI, or go back to the page"]]});function bZA(A){return typeof A==="string"?{kind:A,experimental:!1}:{kind:A.kind??"company",experimental:A.experimental===!0}}function aH(A,Q="company"){let{kind:B,experimental:E}=bZA(Q),I=PQQ.filter((D)=>(B!=="personal"||!vQQ.has(D.id))&&(E||D.group!=="experimental"));if(A==="admin")return I;if(A==="contributor")return I.filter((D)=>D.group==="experimental");return I.filter((D)=>!wQQ.includes(D.id))}function kZA(A,Q="company"){let{kind:B}=bZA(Q),E=new Set(aH(A,Q).map((I)=>I.group));if(A==="contributor")return[{id:"developer",label:"Developer"},...E.has("experimental")?[{id:"experimental",label:vZA("experimental",B)}]:[]];return ih.filter((I)=>E.has(I)).map((I)=>({id:I,label:vZA(I,B)}))}function vZA(A,Q="company"){return(Q==="personal"?bQQ[A]:void 0)??SQQ[A]}var ih,PQQ,SQQ,wQQ,vQQ,bQQ;var nh=W(()=>{yh();ih=["company","reminders","people","money","email","ai","developer","experimental"],PQQ=[{id:"organization",label:"Details",title:"Company details",group:"company"},{id:"categories",label:"Categories",title:"Categories",group:"company"},{id:"documents",label:"Invoices",title:"Invoice settings",group:"company"},{id:"data",label:"Your data",title:"Your data",group:"company"},{id:"reminders",label:"Emails",title:"Reminder emails",group:"reminders"},{id:"receipt-reminders",label:"Receipts",title:"Receipt reminders",group:"reminders"},{id:"deadlines",label:"Deadlines",title:"Deadlines and filings",group:"reminders"},{id:"regulations",label:"Tax rules",title:"Tax rule changes",group:"reminders"},{id:"people",label:"Team",title:"Team members",group:"people"},{id:"accountants",label:"Accountants",title:"Accountant access",group:"people"},{id:"joining",label:"Alerts",title:"New people alerts",group:"people"},{id:"connections",label:"Banks and payments",title:"Bank connections",group:"money"},{id:"mail",label:"Addresses",title:"Email addresses",group:"email"},{id:"senders",label:"Senders",title:"Approved senders",group:"email"},{id:"email-types",label:"Sorting",title:"Email sorting",group:"email"},{id:"sending",label:"Sending",title:"Sending addresses",group:"email"},{id:"ai-keys",label:"AI keys",title:"AI keys",group:"ai"},{id:"connectors",label:"Connectors",title:"Data connectors",group:"developer"},{id:"experiments",label:"Experiments",title:"Experimental features",group:"experimental"}],SQQ={company:"Company",reminders:"Reminders",people:"People",money:"Banks and payments",email:"Email",ai:"AI keys",developer:"Developer",experimental:"Experimental"},wQQ=["organization","documents","data","reminders","receipt-reminders","deadlines","regulations","people","accountants","joining","connections","mail","senders","email-types","sending","ai-keys","connectors"];vQQ=new Set(["people","joining"]);bQQ={company:"Workspace",people:"Accountants"}});function LM(A,Q={}){let B=A==="owner"?"/finance/financial-statements":"/accountant/financial-statements",E=new URLSearchParams;if(Q.period)E.set("from",Q.period.from),E.set("to",Q.period.to);if(Q.report)E.set("report",Q.report);if(Q.send)E.set("send","1");if(Q.packages)E.set("packages","1");if(Q.review)E.set("review","1");let I=E.toString();return I?`${B}?${I}`:B}function kQQ(A){return[["balance_sheet","Balance sheet"],["income_statement","Income statement"],["trial_balance","Trial balance"],["general_ledger","General ledger"],["gst_hst","GST/HST summary"],...A?[]:[["contractors","Contractors and T4A slips"]]].map(([B,E])=>({id:`fs:${B}`,label:E,parent:"Financial statements",href:LM("owner",{report:B}),kind:"view",area:"financialStatements",keywords:$B[`fs:${B}`]??[]}))}function wD(A){if(!A)return[];let Q=A.id==="ai"?"ai":A.id;return A.groups.flatMap((B)=>B.links.map((E)=>{let I=E.id.startsWith("mailbox-")?E.id.slice(8):null;return{id:`${A.id}:${E.id}`,label:A.id==="insights"&&E.id==="tax"?"Tax workpaper":E.label,parent:I?"Inbox · Mailboxes":xQQ[A.id],href:E.href,kind:"view",area:Q,keywords:I?["mailbox",`${I} mail`,`${I} email`]:$B[`${A.id}:${E.id}`]??[]}}))}function yZA(A,Q=!1,B="company"){let E=A==="admin",I=A!=="contributor",D=B==="personal",J=q$(A,Q,B),G=(Y)=>J.some((H)=>H.id===Y),U=J.map((Y)=>({id:`page:${Y.id}`,label:Y.label,href:Y.href,kind:"page",area:Y.id,keywords:$B[`page:${Y.id}`]??[]}));if(G("budgets"))U.push({id:"budgets:spending",label:"Spending plans",parent:"Budgets",href:"/finance/budgets?part=spending",kind:"view",area:"budgets",keywords:["budget","monthly spending","category limit","plan"]},{id:"budgets:reserves",label:"Reserve accounts",parent:"Budgets",href:"/finance/budgets?part=reserves",kind:"view",area:"budgets",keywords:["wise reserve","hst account","tax account","set aside","account purpose"]});if(U.push(...wD(E1("transactions",A))),U.push(...wD(E1("inbox",A,!1,B))),U.push(...wD(E1("ai",A))),G("developers"))U.push(...wD(E1("developers",A)));if(G("chiefOfStaff"))U.push(...wD(E1("chiefOfStaff",A,Q)).filter((Y)=>Y.id!=="chiefOfStaff:overview"));if(U.push(...wD(E1("compliance",A,Q))),U.push(...wD(E1("people",A,!1,B)).filter((Y)=>Y.href?.startsWith("/people/recruiting"))),U.push(...wD(E1("insights",A))),U.push(...wD(E1("invoices",A)).map((Y)=>Y.id==="invoices:archived"?{...Y,label:"Archived invoices"}:Y.id==="invoices:archived_accounts"?{...Y,label:"Archived customers and vendors"}:Y.id==="invoices:scheduled"?{...Y,label:"Scheduled invoices"}:Y)),G("contractors"))U.push(...nH.filter((Y)=>Y.view!=="settings"||E).map((Y)=>({id:`contractors:${Y.view}`,label:Y.label,parent:"Contractors",href:Y.href,kind:"view",area:"contractors",keywords:$B[`contractors:${Y.view}`]??[]})));if(U.push(...kZA(A,B).map((Y)=>({id:`settings:${Y.id}`,label:Y.label,parent:"Settings",href:`/settings?section=${Y.id}`,kind:"setting",area:"settings",keywords:$B[D&&Y.id==="people"?"settings:accountants":`settings:${Y.id}`]??[]}))),U.push(...aH(A,B).filter((Y)=>!ih.includes(Y.id)).map((Y)=>({id:`settings:${Y.id}`,label:Y.title,parent:"Settings",href:`/settings?section=${Y.id}`,kind:"setting",area:"settings",keywords:$B[`settings:${Y.id}`]??[]}))),I)U.push({id:"documents:all",label:"All agreements",parent:"Agreements",href:"/legal/agreements",kind:"view",area:"documents",keywords:$B["documents:all"]},...D?[]:[{id:"documents:contracts",label:"Contracts",parent:"Agreements",href:"/legal/agreements?view=contracts",kind:"view",area:"documents",keywords:$B["documents:contracts"]},{id:"documents:jobs",label:"Jobs",parent:"Agreements",href:"/legal/agreements?view=jobs",kind:"view",area:"documents",keywords:$B["documents:jobs"]}],{id:"documents:templates",label:"Agreement templates",parent:"Agreements",href:"/legal/agreements?view=templates",kind:"view",area:"documents",keywords:$B["documents:templates"]},{id:"checklist:calendar",label:"Calendar",parent:"Checklist",href:"/calendar",kind:"view",area:"checklist",keywords:$B["checklist:calendar"]},{id:"reports:stripe",label:"Stripe activity",parent:"Reports",href:"/finance/reports?view=stripe",kind:"view",area:"reports",keywords:$B["reports:stripe"]},{id:"tax:info",label:"Tax info",parent:"Taxes",href:"/finance/tax/info",kind:"view",area:"taxInfo",keywords:$B["tax:info"]},{id:"tax:prep",label:"Year-end",parent:"Taxes",href:"/finance/tax",kind:"view",area:"tax",keywords:$B["tax:prep"]},{id:"tax:corporate",label:"Corporate tax (T2)",parent:"Taxes",href:"/finance/tax?kind=corporate",kind:"view",area:"tax",keywords:$B["tax:corporate"]},{id:"tax:gst",label:"GST/HST return",parent:"Taxes",href:"/finance/tax?kind=gst_hst",kind:"view",area:"tax",keywords:$B["tax:gst"]},{id:"tax:setup",label:"Company and tax setup",parent:"Taxes",href:"/finance/tax/setup",kind:"view",area:"tax",keywords:$B["tax:setup"]},...kQQ(D),{id:"tax:stripe",label:"Stripe for the year",parent:"Taxes",href:"/finance/tax?view=stripe",kind:"view",area:"tax",keywords:$B["tax:stripe"]},{id:"tax:records",label:"Tax records",parent:"Taxes",href:"/finance/tax?view=records",kind:"view",area:"tax",keywords:$B["tax:records"]},{id:"tax:shareholders",label:"Shareholders",parent:"Taxes",href:"/finance/tax?view=shareholders",kind:"view",area:"tax",keywords:$B["tax:shareholders"]},{id:"tax:file-gst",label:"File your GST/HST return",parent:"Taxes",href:"/finance/tax?view=gst-hst",kind:"view",area:"tax",keywords:$B["tax:file-gst"]},{id:"tax:file-t2",label:"File your corporate tax return (T2)",parent:"Taxes",href:"/finance/tax?view=t2",kind:"view",area:"tax",keywords:$B["tax:file-t2"]},...D?[]:[{id:"tax:file-slips",label:"File contractor slips (T4A)",parent:"Taxes",href:"/finance/tax?view=slips",kind:"view",area:"tax",keywords:$B["tax:file-slips"]}]);if(U.push({id:"action:upload",label:"Add receipt",kind:"action",area:"inbox",run:"upload",keywords:$B["action:upload"]}),U.push({id:"action:intake",label:"Upload files",kind:"action",area:"inbox",run:"intake",keywords:$B["action:intake"]}),I)U.push({id:"action:import",label:"Import bank CSV",kind:"action",area:"transactions",run:"import",keywords:$B["action:import"]},{id:"action:invoice",label:"Create an invoice",kind:"action",area:"invoices",href:"/finance/invoices/new",keywords:$B["action:invoice"]},{id:"action:sign",label:"Send a document for signature",kind:"action",area:"documents",href:"/legal/agreements/new",keywords:$B["action:sign"]},...D?[]:[{id:"action:contractor",label:"Add a contractor",kind:"action",area:"contractors",href:"/people/contractors?new=contractor",keywords:$B["action:contractor"]}]);if(A==="admin"||A==="finance")U.push({id:"action:sendAccountant",label:"Send to your accountant",kind:"action",area:"financialStatements",href:LM("owner",{send:!0}),keywords:$B["action:sendAccountant"]},{id:"fs:packages",label:"Packages you sent",parent:"Financial statements",href:LM("owner",{packages:!0}),kind:"view",area:"financialStatements",keywords:$B["fs:packages"]});if(E)U.push({id:"action:accountant",label:"Invite your accountant",kind:"action",area:"settings",href:"/settings?section=accountants&invite=accountant",keywords:$B["action:accountant"]},...D?[]:[{id:"action:members",label:"Invite a teammate",kind:"action",area:"settings",href:"/settings?section=people",keywords:$B["action:members"]}]);return U.push(...G("developers")?[{id:"action:apiKey",label:"Create an API key",kind:"action",area:"developers",href:"/developers?view=keys&new=key",keywords:$B["action:apiKey"]}]:[],{id:"action:inbox",label:"Connect Gmail or Outlook",kind:"action",area:"inbox",href:"/inbox?view=connected",keywords:$B["action:inbox"]}),U}function oH(A){return A.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLocaleLowerCase().replace(/&/g," and ").replace(/[^a-z0-9]+/g," ").trim()}function yQQ(A,Q){let B=0;for(let E of A){if(B=Q.indexOf(E,B),B<0)return!1;B+=1}return!0}function WM(A,Q){let B=oH(Q);if(!B)return 1;let E=oH(A.label),I=oH(A.parent??""),D=A.keywords.map(oH);if(E===B)return 100;if(E.startsWith(B))return 90;if(D.includes(B))return 85;if(E.split(" ").some((G)=>G.startsWith(B)))return 80;if(D.some((G)=>G.startsWith(B)))return 75;if(D.some((G)=>G.split(" ").some((U)=>U.startsWith(B))))return 70;let J=B.split(" ");if(J.length>1){let G=E.split(" "),U=D.flatMap((X)=>X.split(" ")),Y=I.split(" ").filter(Boolean),H=0;for(let X of J){let N=G.includes(X)?3:G.some((z)=>z.startsWith(X))?2:U.includes(X)?2:U.some((z)=>z.startsWith(X))||Y.some((z)=>z.startsWith(X))?1:0;if(!N){H=-1;break}H+=N}if(H>0)return Math.min(69,55+H)}if(E.includes(B))return 50;if(B.length>=4&&J.length===1&&[E.replaceAll(" ",""),...D.map((G)=>G.replaceAll(" ",""))].some((G)=>yQQ(B,G)))return 20;return 0}function fZA(A,Q,B=12){if(!oH(Q))return A.filter((E)=>E.kind==="page"||E.kind==="action");return A.map((E,I)=>({entry:E,position:I,score:WM(E,Q)})).filter((E)=>E.score>0).sort((E,I)=>I.score-E.score||xZA[E.entry.kind]-xZA[I.entry.kind]||E.position-I.position).slice(0,B).map((E)=>E.entry)}var $B,xQQ,xZA;var hZA=W(()=>{mU();nh();$B={"page:home":["dashboard","overview","start","needs you","today","to do","todo","tasks"],"page:inbox":["email","mail","messages","receipts","forwarded","documents"],"page:transactions":["expenses","spending","purchases","payments","bank","card","ledger","books","entries","bookkeeping"],"page:invoices":["billing","bills","receivables","sales","customers","accounts receivable","quotes"],"page:documents":["documents","contracts","sign","signature","e-sign","esign","nda","envelopes","docusign"],"page:people":["recruiting","hiring","jobs","candidates","applicants","ats","interviews"],"people:postings":["job posting","jobs","hiring","recruiting","candidates","applicants","pipeline","open role"],"people:interviews":["interview","scorecard","feedback","candidates"],"people:board":["careers page","job board","public jobs","careers"],"page:contractors":["freelancers","consultants","workers","people","vendors","timesheets","hours","payouts","payroll"],"page:checklist":["compliance","deadlines","due dates","filings","reminders","to do","todo","tasks","cra"],"page:taxInfo":["tax","taxes","gst","hst","sales tax","t2","corporate tax","income tax","cra","returns","filing","tax prep"],"page:budgets":["budget","budgeting","spending plan","reserve","reserves","set aside","tax savings","cash coverage"],"page:reports":["summary","money in","money out","cash","export","analytics","spending report"],"page:financialStatements":["financial statements","statements","accountant","reports for your accountant","accountant reports","year-end reports","excel","pdf","gifi","download statements"],"fs:balance_sheet":["assets","liabilities","equity","net worth","what we own"],"fs:income_statement":["profit and loss","p&l","pnl","profit","loss","revenue","expenses","net income","earnings"],"fs:trial_balance":["debits","credits","tb","accounts"],"fs:general_ledger":["ledger","gl","postings","journal"],"fs:gst_hst":["gst report","hst report","sales tax report","gst summary","itc","input tax credits"],"fs:contractors":["t4a list","contractor report","contractor payments","t4a slips"],"fs:packages":["sent packages","who downloaded","package links","packages sent"],"page:insights":["analytics","trends","spend","people cost","projects","tax"],"insights:finance":["spend","revenue","income","profit","loss","categories"],"insights:people":["contractor cost","hours","punctuality","timesheets"],"insights:projects":["project costs","tags","overlap"],"insights:tax":["gst","hst","readiness","workpaper"],"insights:map":["world map","locations","city counts","geography","venue map","transaction map"],"page:ai":["autopilot","automation","jobs","assistant","machine learning","run ai"],"page:chiefOfStaff":["chief of staff","discord","bot","agent","server","channels","permissions","rules","community"],"chiefOfStaff:server":["discord server","channels","channel rules","per channel","replies","mentions only"],"chiefOfStaff:people":["discord roles","permissions","people rules","access","organizers"],"chiefOfStaff:tools":["discord tools","luma","guest lists","web search","github","access","integrations"],"chiefOfStaff:schedules":["scheduled posts","cron","good morning","ai news","pause posts"],"chiefOfStaff:activity":["discord metrics","tokens","requests","gateway"],"chiefOfStaff:settings":["pause chief of staff","direct messages","ignore people","block"],"page:compliance":["compliance","legal","hiring","job posting","contractor","employment standards","nda","privacy","payroll","rules","research","library","regulation"],"compliance:ask":["ask","question","chat","assistant","official sources","article","best practices","research"],"compliance:library":["library","guides","best practices","notes","entries","rules","sources","nda","knowledge"],"compliance:items":["open items","regulation updates","suggestions","settings changes","rules to review","decisions","platform changes"],"compliance:research":["what's new","run research","check for new rules","pages we watch","known rules","schedule"],"page:logs":["observability","observe","runs","traces","tracing","events","debug","errors","failures","workflows","monitoring","developer"],"page:history":["history","audit","audit log","audit trail","activity","changes","change log","who changed","undo","roll back","rollback","revert","restore","track changes"],"page:settings":["preferences","configuration","config","options","admin"],"page:developers":["developer","developer portal","api","rest api","integrations","build","sdk","programmatic","automation"],"page:godMode":["god mode","admin","platform","waitlist","sign-ups","signups","approve","workspaces","organizations","spend","ai usage"],"developers:overview":["developer portal","get started","api base url","first request"],"developers:keys":["api key","api keys","keys","tokens","secret","credentials","bearer","rotate key","revoke key"],"developers:webhooks":["webhook","events","callbacks","endpoints","signing secret","deliveries","notifications"],"developers:usage":["analytics","api usage","requests","traffic","error rate","latency","response time","metrics","webhook deliveries"],"developers:requests":["request log","logs","request id","x-request-id","api errors","failed requests","debug"],"developers:connect":["mcp","claude","chatgpt","cursor","ai apps","connect an agent","terminal","cli"],"developers:docs":["documentation","docs","api reference","guides","tutorials","openapi","llms.txt"],"transactions:all":["everything","all expenses","list"],"transactions:needs_you":["review","attention","to do","todo","action needed","missing receipts","questions"],"transactions:working":["in progress","processing","pending","queue","ai working"],"transactions:done":["reviewed","finished","completed","closed","booked"],"transactions:matching":["reconcile","reconciliation","match receipts","receipt matches","pair receipts"],"transactions:stripe":["reconcile","reconciliation","stripe","deposits","payouts","fees"],"transactions:bank":["reconcile","reconciliation","bank records","statement lines","close period","close the books","month end"],"transactions:merchants":["vendors","suppliers","who we paid","payees","spend by merchant","companies","top vendors","slack","profile"],"transactions:trips":["travel","hotel","hotels","stay","hotel hold","holds","map","places","location","business trip","flights","rides"],"transactions:accounts":["bank accounts","cards","credit cards","import","csv","statements","upload statement","wise","rbc"],"transactions:statements":["bank statements","wise statements","monthly statement","statement pdf","originals","statement files","credit card statements"],"inbox:receipts":["invoices","bills","uploads","documents","receipts to review"],"inbox:email":["mail","messages","all mail","company email"],"inbox:quarantine":["spam","blocked","suspicious","held mail","security","phishing"],"inbox:connected":["gmail","google","outlook","microsoft","office 365","connect email","connect inbox","inbox scanning"],"inbox:mine":["my uploads","my receipts","receipts"],"inbox:uploads":["uploads","upload history","files","dropped files","where did my file go","added files","intake"],"ai:overview":["autopilot","jobs","status","run a job","run ai"],"ai:classifiers":["models","thresholds","routing","matching model","classification","certainty","confidence"],"ai:playground":["harness","console","sandbox","test","try"],"ai:memory":["rules","learned rules","merchant rules","notes","knowledge","context"],"ai:agents":["agents","monitor","live","running","runs","activity","what is ai doing","agent status","inbox scanner","matcher"],"ai:connections":["mcp","api","api keys","keys","tokens","developer","integrations","claude","chatgpt","cursor","connect an agent"],"ai:settings":["autopilot settings","receipt minimum","receipt threshold","grace days","automation settings"],"contractors:directory":["all contractors","list","people","contacts","portal access"],"contractors:timesheets":["hours","time","time sheets","approvals","approve hours"],"contractors:history":["past timesheets","all entries","unpaid","paid","owed","mark paid","imported hours","timesheet log"],"contractors:payouts":["payments","pay","pay contractors","wise","transfers","send money","payroll"],"contractors:hours-form":["form","fields","custom fields","timesheet form"],"contractors:activity":["log","history","audit"],"contractors:setup":["contractor setup","more contractor pages"],"contractors:roles":["levels","pay bands","titles"],"contractors:import":["spreadsheet","csv","add several","bulk"],"contractors:insights":["contractor cost","spend","how much"],"contractors:templates":["agreement templates","contracts","documents"],"contractors:tax":["t4a","t4a-nr","slips","1099","w-9","w9","year end","calendar year","tax forms","reporting","cra","irs"],"contractors:email":["notifications","emails sent","delivery","email log"],"contractors:documents":["contractor documents","invoices","contractor invoices","files","records"],"contractors:settings":["reminders","approvers","approvals","pay schedule","cadence","wise settings","payout settings"],"settings:company":["company","business","organization","profile","categories","reminders","invoicing"],"settings:money":["bank","banks","wise","stripe","rbc","connect bank","sync","money"],"settings:email":["email","classifiers","senders","forwarding","routing","mail rules","inbound","email in","receipts"],"settings:developer":["developer","connectors","data sources","notion","google drive"],"settings:ai":["ai keys","api key","openai","typesafe","jev","gemini","google","ai gateway","vercel","byok","bring your own key","z.ai","glm"],"settings:ai-keys":["ai keys","openai key","typesafe key","gemini key","ai gateway key","byok"],"settings:organization":["company","business","legal name","fiscal year","year end","address","logo","business number","profile"],"settings:accountants":["accountant","accountants","bookkeeper","cpa","permissions","share books","invite","access"],"settings:people":["members","team","teammates","users","invite","roles","permissions","access","accountant"],"settings:mail":["email","classifiers","senders","forwarding","routing","mail rules"],"settings:categories":["chart of accounts","coa","expense categories","gifi","accounts"],"settings:connections":["bank","banks","wise","stripe","rbc","connect bank","sync"],"settings:connectors":["notion","integrations","data sources","crm","import data"],"settings:documents":["invoicing","invoice numbering","letterhead","branding","logo","payment methods","templates"],"settings:reminders":["notifications","compliance reminders","emails","alerts","deadlines","due dates"],"settings:receipt-reminders":["missing receipts","receipt chase","cardholders","card receipts"],"settings:deadlines":["filings","payroll","instalments","annual return","t4","t5018","incorporation"],"settings:regulations":["regulation updates","tax rules","law changes","official sources"],"settings:joining":["new people","joins","join notices","notifications"],"settings:senders":["approved senders","blocked senders","allowed senders","vendor emails"],"settings:email-types":["classifiers","email types","routing","guidance","sorting"],"settings:sending":["email domain","custom domain","dns","sending names","from address","test email"],"invoices:all":["all invoices","sent invoices"],"invoices:needs_action":["approve invoices","invoices to send","late payments"],"invoices:open":["unpaid invoices","receivables","accounts receivable","owed"],"invoices:overdue":["late invoices","past due","collections"],"invoices:paid":["paid invoices","collected"],"invoices:draft":["draft invoices","unsent"],"invoices:scheduled":["recurring","subscriptions","schedules","payment plans","automation"],"invoices:uncollectible":["written off","bad debt","uncollectible"],"invoices:void":["cancelled invoices","void","voided"],"invoices:archived":["archived invoices","old invoices"],"invoices:customers":["clients","customers","parties","contacts"],"invoices:vendors":["vendors","suppliers"],"invoices:archived_accounts":["archived customers","archived vendors","former clients"],"documents:all":["envelopes","signatures","sent documents","documents"],"documents:templates":["agreement templates","nda","contract templates"],"documents:contracts":["contractor contracts","contractor agreements","employee contracts","expiring","expired","ending agreements","active agreements","renewals","timeline"],"documents:jobs":["job descriptions","job roles","roles","pay bands","positions"],"checklist:calendar":["dates","important dates","deadlines","schedule","paydays","pay dates"],"reports:stripe":["stripe","fees","revenue","stripe report"],"tax:gst":["gst","hst","sales tax","gst return","hst return","itc","input tax credits"],"tax:corporate":["t2","corporate","income tax","year end","year-end","gifi"],"tax:setup":["business number","bn","gst registration","hst registration","fiscal year","company details","tax setup"],"tax:info":["taxes","tax info","tax information","hst","gst","gst/hst number","gst number","hst number","rt0001","registration date","gst registration date","hst registration date","business number","filing frequency","tax due dates","due dates","tax deadlines","fiscal year-end","year-end date","incorporation","incorporation date","corporation number","tax documents","registrations"],"tax:prep":["year end","year-end","t2","corporate tax","gifi","tax prep","preparation","returns","filing","accountant"],"tax:file-gst":["file gst","file hst","gst/hst return","netfile","my business account","pay gst","pay hst","hst payment","confirmation number","line 101","line 103","line 106","input tax credits","itc","file it yourself"],"tax:shareholders":["shareholders","shareholder register","share register","cap table","shares","share classes","class a","common shares","directors","officers","schedule 50","dividends","t5","who owns"],"tax:file-t2":["t2","file t2","corporate tax return","corporation income tax","balance due","pay corporate tax","schedule 50","schedule 125","schedule 100","gifi","certified software","notice of assessment","file it yourself"],"tax:file-slips":["t4a","t4a slips","t4a-nr","t4a summary","file slips","contractor slips","web forms","box 048","us contractors","w-8ben","file it yourself"],"tax:stripe":["stripe","gross","fees","payouts","charges","refunds","disputes","chargebacks","stripe fees","bank charges","stripe for the year","stripe year-end"],"tax:records":["records","notice of assessment","noa","reassessment","filed returns","t2 return","gst return","cra letters","payment confirmation","slips","t4","t4a","company documents","articles","bylaws","minute book"],"action:intake":["drop","upload","import","receipts","statement","bank statement","csv","bill","invoice","tax document","notice of assessment","noa","t2","gst return","cra","agreement","contract","company document","articles","bylaws","file","files","attach","add files","new"],"action:upload":["upload","receipt","photo","camera","scan","new","add expense","expense"],"action:import":["import","csv","statement","bank statement","upload statement","new"],"action:invoice":["new invoice","bill a customer","invoice","new"],"action:sign":["sign","signature","agreement","contract","nda","esign","e-sign","new"],"action:contractor":["new contractor","hire","onboard","contractor","new"],"action:accountant":["accountant","bookkeeper","cpa","invite","share books"],"action:sendAccountant":["year-end package","package","accountant package","send to accountant","send to my accountant","zip","send everything","everything for the accountant","handoff","share with accountant","statements pack","send books","year end"],"action:members":["invite","teammate","member","user","team"],"action:apiKey":["api key","token","developer","mcp","new key"],"action:inbox":["gmail","outlook","connect gmail","connect outlook","connect inbox","scan email"]};xQQ={chiefOfStaff:"Chief of Staff",developers:"Developers",transactions:"Transactions",inbox:"Inbox",ai:"AI",compliance:"Compliance",tax:"Taxes",people:"People",documents:"Agreements",insights:"Insights",invoices:"Invoices",godMode:"God Mode"};xZA={page:0,view:1,setting:2,action:3}});import{mkdir as fQQ,readFile as hQQ,writeFile as uQQ}from"node:fs/promises";import{join as mQQ}from"node:path";import{createHash as cQQ}from"node:crypto";function rH(A){return A==="access"||A==="destructive"||A==="external"}function pQQ(A,Q){return lQQ.get(A)??(Q?"read":"write")}function dQQ(A){let Q=[];for(let[B,E]of Object.entries(A.paths??{})){let I=/^\/api\/v1\/accounting\/([^/]+)$/.exec(B),D=E.post;if(!I||!D)continue;let J=D["x-read-only"]===!0;Q.push({name:I[1],summary:D.summary??"",readOnly:J,scopes:[...D["x-required-scopes"]??[]],roles:[...D["x-allowed-roles"]??[]],kind:pQQ(I[1],J),inputSchema:D.requestBody?.content?.["application/json"]?.schema??{type:"object"}})}return Q.sort((B,E)=>B.name.localeCompare(E.name))}function jM(A,Q){let B=Q.toLowerCase().split(/\s+/).filter(Boolean);if(!B.length)return[...A];return A.map((I)=>{let D=I.name.toLowerCase(),J=D.split(/[._]/),G=B.every((H)=>D.includes(H)),U=B.every((H)=>D.includes(H)||I.summary.toLowerCase().includes(H)),Y=D.startsWith(B.join("."))||D===B.join("")?4:G&&J.some((H)=>H.startsWith(B[0]))&&D.startsWith(B[0])?3:G?2:U?1:0;return{action:I,score:Y}}).filter((I)=>I.score>0).sort((I,D)=>D.score-I.score||I.action.name.length-D.action.name.length||I.action.name.localeCompare(D.action.name)).map((I)=>I.action)}function RM(A){return!!A?.inputSchema.properties&&"idempotencyKey"in A.inputSchema.properties}function nQQ(A){return mQQ(nG(),`actions-${cQQ("sha256").update(A).digest("hex").slice(0,16)}.json`)}async function M$(A,Q={}){let B=nQQ(A),E=await hQQ(B,"utf8").then((D)=>JSON.parse(D)).catch(()=>null);if(E&&!Q.fresh&&Date.now()-E.fetchedAt<iQQ)return E.actions;let I=Q.fetch??fetch;try{let D=await I(`${A}/api/openapi.json`,{headers:{...p8(),accept:"application/json",...E?.etag?{"if-none-match":E.etag}:{}},redirect:"error"});if(D.status===304&&E)return await uZA(B,{...E,fetchedAt:Date.now()}),E.actions;if(!D.ok)throw Error(`HTTP ${D.status}`);let J=dQQ(await D.json());return await uZA(B,{fetchedAt:Date.now(),etag:D.headers.get("etag"),actions:J}),J}catch(D){if(E)return E.actions;throw Error(`Couldn't load Oatmilk's list of actions: ${D instanceof Error?D.message:String(D)}`)}}async function uZA(A,Q){await fQQ(nG(),{recursive:!0}).catch(()=>{return}),await uQQ(A,JSON.stringify(Q)).catch(()=>{return})}var lQQ,iQQ=86400000;var gM=W(()=>{$h();AJ();D6();lQQ=new Map(Object.values(xH).map(([A,Q])=>[A,Q]))});function f0({color:A=L.accent,label:Q}){let{frame:B}=x1({interval:80});return d(f,{color:A,children:[j8[B%j8.length],Q?d(f,{color:L.muted,children:[" ",Q]}):null]})}var vD=W(async()=>{bB();HQ();await dB()});function mZA({width:A,height:Q,onClose:B,onUpload:E}){let I=FB(),D=XG(),[J,G]=qE.useState({value:"",cursor:0}),[U,Y]=qE.useState(0),[H,X]=qE.useState(null),[N,z]=qE.useState([]),F=I.role==="admin"||I.role==="finance",V=qE.useMemo(()=>yZA(I.role,!1,I.identity.workspaceKind),[I.role,I.identity.workspaceKind]);qE.useEffect(()=>{M$(I.session.host).then(z,()=>{return})},[I.session.host]);let O=qE.useRef(0),j=J.value.trim(),b=qE.useMemo(()=>H?.query===j?H.items:[],[H,j]),x=j.length>=2&&H?.query!==j;qE.useEffect(()=>{O.current+=1;let CA=O.current;if(j.length<2)return;let GA=setTimeout(()=>{let iA=(IQ)=>()=>{B(),I.navigate(IQ,{focus:"main"})},jA=[I.api.call("entries.list",{search:j,limit:6},{readOnly:!0}).then((IQ)=>IQ.map((_A)=>({key:`entry:${_A.id}`,group:"Transactions",label:_A.merchant??"Transaction",detail:`${aQ(_A.amount_minor,_A.currency)} · ${oQ(_A.date)}`,run:iA(`/finance/transactions?entry=${_A.id}`)})))];if(F)jA.push(I.api.call("mail.list",{search:j,limit:4},{readOnly:!0}).then((IQ)=>IQ.items.map((_A)=>({key:`mail:${_A.id}`,group:"Email",label:_A.subject??"(no subject)",detail:`${_A.sender_email??""} · ${oQ(_A.received_at)}`,run:iA(`/inbox?view=email&mail=${_A.id}`)}))),I.api.call("invoices.list",{search:j,limit:4,offset:0},{readOnly:!0}).then((IQ)=>IQ.items.map((_A)=>({key:`invoice:${_A.id}`,group:"Invoices",label:`${_A.number??"Draft"} · ${_A.party_name??""}`,detail:aQ(_A.total_minor,_A.currency),run:iA(`/finance/invoices?invoice=${_A.id}`)}))),I.api.call("contractors.list",{query:j,limit:4,offset:0},{readOnly:!0}).then((IQ)=>IQ.items.map((_A)=>({key:`contractor:${_A.id}`,group:"Contractors",label:_A.display_name,detail:_A.email??"",run:iA(`/people/contractors?contractor=${_A.id}`)}))));Promise.allSettled(jA).then((IQ)=>{if(CA!==O.current)return;X({query:j,items:IQ.flatMap((_A)=>_A.status==="fulfilled"?_A.value:[])})})},220);return()=>clearTimeout(GA)},[j,I.api,I.navigate,F,B,I]);let v=qE.useMemo(()=>{let CA=(uA)=>({key:uA.id,group:uA.kind==="action"?"Do":"Go to",label:uA.label,detail:uA.parent,run:()=>{if(B(),uA.run==="upload")E();else if(uA.run)I.navigate("/inbox?view=uploads",{focus:"main"});else if(uA.href)I.navigate(uA.href,{focus:"main"})}}),GA=fZA(V,j,j?8:40),iA=j?GA.filter((uA)=>WM(uA,j)>=50).map(CA):GA.map(CA),jA=j?GA.filter((uA)=>WM(uA,j)<50).slice(0,3).map(CA):[],IQ=j?[{key:"ask",group:"Ask AI",label:`Ask Oatmilk: "${j}"`,run:()=>{B(),I.ask(j)}}]:[],_A=j.toLowerCase().split(/\s+/).filter(Boolean),RB=j?N.filter((uA)=>_A.every((sA)=>uA.name.toLowerCase().includes(sA)||uA.summary.toLowerCase().includes(sA))).slice(0,5).map((uA)=>({key:`action:${uA.name}`,group:"Run an action",label:uA.name,detail:uA.summary.slice(0,60),run:()=>{B(),I.navigate(`${D1}?action=${encodeURIComponent(uA.name)}`,{focus:"main"})}})):[],YA=[{key:"cli:new-chat",group:"Ask AI",label:"New chat",run:()=>{B(),I.chat.start(null),I.setChatVisible(!0),I.setFocus("composer")}},{key:"cli:chats",group:"Ask AI",label:"Recent chats",run:()=>{I.setOverlay("chats")}},{key:"cli:org",group:"Do",label:"Switch workspace",run:()=>{I.setOverlay("orgs")}},{key:"cli:actions",group:"Do",label:"Run an action",run:()=>{B(),I.navigate(D1,{focus:"main"})}},{key:"cli:themes",group:"Theme",label:"Themes…",detail:D.shownName,run:()=>{I.setOverlay("theme")}}].filter((uA)=>!j||_A.every((sA)=>uA.label.toLowerCase().includes(sA))),yA=["theme","themes","appearance","color","colors","colour","mode","dark","light","night","day"],YQ=(uA)=>_A.every((sA)=>uA.toLowerCase().includes(sA)),yQ=j?KG().filter((uA)=>_A.every((sA)=>uA.name.toLowerCase().includes(sA)||yA.some((qQ)=>qQ.startsWith(sA)))).sort((uA,sA)=>Number(YQ(sA.name))-Number(YQ(uA.name))).slice(0,6).map((uA)=>({key:`theme:${uA.id}`,group:"Theme",label:uA.name,detail:uA.id===D.choice?"current":void 0,run:()=>{B(),D.choose(uA.id),I.toast(`Theme: ${uA.name}`,"success")}})):[],zQ=[...iA,...YA,...yQ,...b.filter((uA)=>aQQ.includes(uA.group)),...RB,...jA];return j?[...zQ,...IQ]:zQ},[V,j,b,N,I,B,E,D]),[w,k]=qE.useState(j);if(w!==j)k(j),Y(0);iQ((CA,GA)=>{if(GA.escape){B();return}if(GA.upArrow){Y((jA)=>Math.max(0,jA-1));return}if(GA.downArrow||GA.tab){Y((jA)=>Math.min(v.length-1,jA+1));return}if(GA.return){v[U]?.run();return}let iA=BI(J,CA,GA,200);if(iA.type==="edit")G(iA.state)}),z8((CA)=>G((GA)=>j4(GA,CA.replace(/\n/g," "),200)));let h=Math.min(90,A-4),t=Math.max(5,Math.min(Q-8,18)),i=Math.max(0,Math.min(U-t+3,v.length-t)),UA=v.slice(i,i+t);return R(e,{position:"absolute",top:0,left:0,width:A,height:Q,justifyContent:"center",alignItems:"flex-start",paddingTop:1,children:d(e,{flexDirection:"column",width:h,borderStyle:"single",borderColor:L.focus,paddingX:1,backgroundColor:L.panel,children:[d(e,{justifyContent:"space-between",children:[R(p0,{state:J,width:h-8,placeholder:"Jump to a page, find a record, run an action, or ask…",prefix:[{text:`${hA.prompt} `,color:L.accent,bold:!0}]}),x?R(f0,{}):null]}),R(f,{color:L.border,children:"─".repeat(h-4)}),UA.map((CA,GA)=>{let iA=i+GA,jA=iA===U,IQ=iA===0||v[iA-1].group!==CA.group;return d(e,{flexDirection:"column",children:[IQ?R(f,{color:L.faint,bold:!0,children:CA.group.toUpperCase()}):null,d(e,{justifyContent:"space-between",children:[d(f,{color:jA?L.focus:L.text,bold:jA,wrap:"truncate-end",children:[jA?hA.pointer:" "," ",CA.label]}),CA.detail?d(f,{color:L.faint,wrap:"truncate-end",children:[" ",CA.detail]}):null]})]},CA.key)}),!v.length?R(f,{color:L.muted,children:x?"Searching…":"Nothing matches. Press ⏎ to ask Oatmilk."}):null,R(f,{color:L.faint,children:"↑↓ choose · ⏎ open · Esc close"})]})})}var qE,aQQ;var cZA=W(async()=>{hZA();gM();d1();RD();qG();NG();bB();BE();bB();HQ();await $0([dB(),gD(),vD()]);qE=pA(JQ(),1),aQQ=["Transactions","Email","Invoices","Contractors"]});function oQQ(A,Q,B,E={},I="company"){let D=Q.startsWith("/cli/")?null:sXA(uU(Q)),J=[];for(let U of MZA(A,!1,I)){J.push({kind:"area",label:U.label.toUpperCase()});for(let Y of U.destinations){let H=Y.id===D;if(J.push({kind:"page",label:Y.label,href:Y.href,active:H,count:E[Y.id]}),!H)continue;for(let X of Y.children){let N=new URL(X.href,"https://x.invalid"),z=N.pathname===Q&&[...N.searchParams].every(([F,V])=>B.get(F)===V);J.push({kind:"child",label:X.label,href:X.href,active:z})}}}let G=q$(A,!1,I).find((U)=>U.id==="settings");if(J.push({kind:"area",label:"MORE"}),G)J.push({kind:"page",label:"Settings",href:G.href,active:D==="settings"});return J.push({kind:"page",label:"Run an action",href:D1,active:Q===D1}),J}function lZA({height:A,counts:Q}){let{role:B,route:E,navigate:I,focus:D,layout:J,identity:G}=FB(),U=sH.useMemo(()=>oQQ(B,E.path,E.params,Q,G.workspaceKind),[B,E.path,E.params,Q,G.workspaceKind]),Y=U.map((b,x)=>b.href?x:-1).filter((b)=>b>=0),H=U.findIndex((b)=>b.active&&b.kind==="child")>=0?U.findIndex((b)=>b.active&&b.kind==="child"):U.findIndex((b)=>b.active),[X,N]=sH.useState(Math.max(0,H)),z=D==="sidebar",[F,V]=sH.useState({focused:z,activeIndex:H});if(F.focused!==z||F.activeIndex!==H){if(V({focused:z,activeIndex:H}),!z&&H>=0)N(H)}iQ((b,x)=>{let v=Math.max(0,Y.indexOf(X)),w=/^(j+|k+)$/.test(b)?b.length:1;if(x.upArrow||/^k+$/.test(b))N(Y[Math.max(0,v-w)]??X);else if(x.downArrow||/^j+$/.test(b))N(Y[Math.min(Y.length-1,v+w)]??X);else if(x.home||b==="g")N(Y[0]);else if(x.end||b==="G")N(Y.at(-1));else if(x.return||x.rightArrow||b==="l"){let k=U[X];if(k?.href)I(k.href,{focus:"main"})}},{isActive:z});let O=J.sidebarWidth,j=Math.max(0,Math.min(X-Math.floor(A/2),U.length-A));return R(e,{flexDirection:"column",width:O,height:A,paddingLeft:1,paddingRight:1,borderStyle:"single",borderTop:!1,borderBottom:!1,borderLeft:!1,borderColor:z?L.focus:L.border,children:U.slice(j,j+A).map((b,x)=>{let v=j+x,w=z&&v===X;if(b.kind==="area")return d(f,{color:L.faint,bold:!0,children:[v===0?"":"",b.label]},v);let k=b.kind==="child"?" ":"",h=w?hA.pointer:b.active?"•":" ",t=w?L.focus:b.active?L.text:b.kind==="child"?L.muted:L.text;return d(e,{justifyContent:"space-between",children:[d(f,{color:t,bold:b.active&&b.kind==="page",wrap:"truncate-end",children:[k,h," ",b.label]}),b.count?R(f,{color:L.highlight,children:b.count>99?"99+":b.count}):null]},v)})})}var sH;var pZA=W(async()=>{mU();qG();BE();bB();HQ();await dB();sH=pA(JQ(),1)});function iZA(A){if(A>=dZA[0].length+4)return dZA;if(A>=pU[0].length+4)return pU;return["◆ oatmilk"]}var dZA,pU;var ah=W(()=>{dZA=[" ██████ █████ ████████ ███ ███ ██ ██ ██ ██","██ ██ ██ ██ ██ ████ ████ ██ ██ ██ ██ ","██ ██ ███████ ██ ██ ████ ██ ██ ██ █████ ","██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ ██ "," ██████ ██ ██ ██ ██ ██ ██ ███████ ██ ██"],pU=["▄▀▀▄ ▄▀▀▄ ▀█▀ █▄▀▄█ █ █ █▄▀","▀▄▄▀ █▀▀█ █ █ ▀ █ █ █▄▄ █ █"]});function oh({text:A,shine:Q,width:B}){let E=[...A],I=[];return E.forEach((D,J)=>{let G=e2A(ZM,B>1?J/(B-1):0),U=Q===void 0?1/0:Math.abs(J-Q),Y=U<6?AXA(G,0.55*(1-U/6)):G,H=I.at(-1);if(H&&H.color===Y)H.text+=D;else I.push({text:D,color:Y})}),R(f,{children:I.map((D,J)=>R(f,{color:D.color,children:D.text},J))})}function rh({columns:A,animate:Q=!0}){let B=iZA(A),E=Math.max(...B.map((J)=>[...J].length)),{frame:I}=x1({interval:40,isActive:Q}),D=Q?I*2%(E+40)-10:void 0;return R(e,{flexDirection:"column",children:B.map((J,G)=>R(oh,{text:J,width:E,shine:D===void 0?void 0:D-G*2},G))})}function i1({columns:A,rows:Q,status:B,working:E=!0,children:I}){return d(e,{width:A,height:Q,flexDirection:"column",alignItems:"center",justifyContent:"center",children:[R(rh,{columns:A}),d(e,{marginTop:1,gap:2,children:[R(f,{color:L.muted,children:"Your company's books, in your terminal"}),d(f,{color:L.faint,children:["v",DI]})]}),R(e,{marginTop:1,minHeight:1,children:E?R(f0,{label:B}):R(f,{color:L.muted,children:B})}),I?R(e,{marginTop:1,flexDirection:"column",alignItems:"center",children:I}):null]})}var tH=W(async()=>{bB();ah();l8();HQ();await $0([dB(),vD()])});function nZA({hints:A,toast:Q}){let{focus:B,chat:E,layout:I}=FB(),D=HG(E),J=B==="main"?A:rQQ[B]??A,G=Q?.tone==="danger"?L.danger:Q?.tone==="warning"?L.warning:Q?.tone==="success"?L.success:L.info;return d(e,{width:I.columns,height:1,overflow:"hidden",paddingX:1,justifyContent:"space-between",children:[Q?d(f,{color:G,wrap:"truncate-end",children:[Q.tone==="danger"?"✗ ":Q.tone==="success"?"✓ ":"• ",Q.message]}):R(f,{color:L.faint,wrap:"truncate-end",children:J}),D.busy?R(e,{flexShrink:0,children:R(f0,{label:B==="composer"?"Ask AI is working · Esc to stop":"Ask AI is working"})}):null]})}var rQQ;var aZA=W(async()=>{BE();pH();bB();HQ();await $0([dB(),vD()]);rQQ={sidebar:"↑↓ move · ⏎ open · Tab next · / ask · q quit",composer:"⏎ send · ⌥⏎ new line · ↑ history · / commands · Esc browse",overlay:"Esc close"}});function rZA({host:A,columns:Q,rows:B,onSignedIn:E,onQuit:I,password:D=!1}){let J=D?[sQQ,...oZA]:oZA,[G,U]=MG.useState({kind:"menu"}),[Y,H]=MG.useState(0),X=MG.useRef(null),N=MG.useRef(null);MG.useEffect(()=>()=>X.current?.abort(),[]);let z=async(O)=>{U({kind:"saving"}),await zB(A,(b)=>({...b,credential:O}));let j=await sQ();j.defaultHost=A,await FI(j),E()},F=(O)=>{if(O==="quit"){I();return}if(O==="key"){U({kind:"key",state:{value:"",cursor:0}});return}if(O==="password"){sQ().then((x)=>{let v=x.hosts[A]?.localAccount?.email??"";U({kind:"password",field:"email",email:v,state:{value:v,cursor:v.length}})});return}X.current?.abort();let j=new AbortController;X.current=j;let b=(x)=>{if(!j.signal.aborted)U({kind:"error",message:CQ(x)})};if(O==="browser"){U({kind:"browser",url:null,opened:!1}),W6({host:A,signal:j.signal,onAuthorizationUrl:async(x)=>{let v=await PE(x);U({kind:"browser",url:x,opened:v})}}).then(z,b);return}U({kind:"paste",url:null,state:{value:"",cursor:0}}),zZ({host:A,onAuthorizationUrl:(x)=>{if(!j.signal.aborted)U({kind:"paste",url:x,state:{value:"",cursor:0}})},readCode:(x)=>new Promise((v)=>{if(N.current=v,x&&!j.signal.aborted)U((w)=>w.kind==="paste"?{...w,state:{value:"",cursor:0},problem:x}:w)})}).then((x)=>{if(!j.signal.aborted)return z(x)},b)};if(iQ((O,j)=>{if(G.kind==="menu"){let b=/^(j+|k+)$/.test(O)?O.length:1;if(j.upArrow||/^k+$/.test(O))H((x)=>Math.max(0,x-b));else if(j.downArrow||/^j+$/.test(O))H((x)=>Math.min(J.length-1,x+b));else if(/^[1-9]$/.test(O)&&Number(O)<=J.length)F(J[Number(O)-1].id);else if(j.return)F(J[Y].id);else if(O==="q"||j.escape)I();return}if(G.kind==="password"){if(j.escape){U({kind:"menu"});return}let b=BI(G.state,O,j,300);if(b.type==="edit"){U({...G,state:b.state});return}if(b.type!=="submit")return;let x=G.state.value.trim();if(G.field==="email"){if(!/^[^\s@]+@[^\s@]+\.[^\s@]+$/.test(x)){U({...G,error:"Enter the email you signed up with."});return}U({kind:"password",field:"password",email:x.toLowerCase(),state:{value:"",cursor:0}});return}if(!G.state.value)return;let v=G.email,w=G.state.value;U({kind:"saving"}),s8({host:A,email:v,password:w}).then((k)=>z(k),(k)=>U({kind:"password",field:"password",email:v,state:{value:"",cursor:0},error:CQ(k)}));return}if(G.kind==="paste"){if(j.escape){X.current?.abort(),N.current=null,U({kind:"menu"});return}let b=BI(G.state,O,j,4000);if(b.type==="submit"&&G.state.value.trim()&&N.current){let x=N.current;N.current=null,U({...G,problem:void 0}),x(G.state.value)}else if(b.type==="edit")U({...G,state:b.state});return}if(G.kind==="key"){if(j.escape){U({kind:"menu"});return}let b=BI(G.state,O,j,200);if(b.type==="submit"){let x=G.state.value.trim();if(!n5(x)){U({...G,error:"That isn't an Oatmilk API key. Keys start with oat_."});return}z({type:"api_key",apiKey:x}).catch((v)=>U({kind:"error",message:CQ(v)}))}else if(b.type==="edit")U({kind:"key",state:b.state});return}if(j.escape||G.kind==="error"&&j.return)X.current?.abort(),U({kind:"menu"})}),G.kind==="menu")return d(i1,{columns:Q,rows:B,status:`Sign in to ${TI(A)}`,working:!1,children:[R(e,{flexDirection:"column",borderStyle:"single",borderColor:L.border,paddingX:2,paddingY:0,width:Math.min(44,Q-4),children:J.map((O,j)=>d(f,{color:j===Y?L.focus:L.text,bold:j===Y,wrap:"truncate-end",children:[j===Y?`${hA.pointer} `:" ",j+1," ",O.label]},O.id))}),R(f,{color:L.muted,children:J[Y].detail||" "}),R(f,{color:L.faint,children:"↑↓ choose · ⏎ continue · q quit"})]});let V=Math.min(Q-4,100);if(G.kind==="browser")return R(i1,{columns:Q,rows:B,status:G.url?"Waiting for you to approve in the browser…":"Opening your browser…",children:G.url?d(e,{flexDirection:"column",alignItems:"center",width:V,children:[R(f,{color:L.muted,children:G.opened?"If the page didn't open, visit:":"Open this address to sign in:"}),R(f,{color:L.info,wrap:"wrap",children:G.url}),R(f,{color:L.faint,children:"Esc to go back"})]}):null});if(G.kind==="paste")return R(i1,{columns:Q,rows:B,status:G.url?"Sign in on any device":"Getting a sign-in link…",working:!G.url,children:G.url?d(e,{flexDirection:"column",alignItems:"center",width:V,children:[R(f,{color:L.muted,children:"Open this address on any device, approve, and copy the code Oatmilk shows:"}),R(e,{marginY:1,children:R(f,{color:L.info,wrap:"wrap",children:G.url})}),R(e,{borderStyle:"single",borderColor:L.focus,paddingX:1,width:Math.min(70,Q-4),children:R(p0,{state:G.state,width:Math.min(66,Q-8),placeholder:"Paste the code here"})}),G.problem?R(f,{color:L.danger,wrap:"wrap",children:G.problem}):R(f,{color:L.faint,children:"⏎ sign in · Esc back"})]}):null});if(G.kind==="key")return d(i1,{columns:Q,rows:B,status:"Paste an API key from Settings › Developer",working:!1,children:[R(e,{borderStyle:"single",borderColor:L.focus,paddingX:1,width:Math.min(70,Q-4),children:R(p0,{state:G.state,width:Math.min(66,Q-8),placeholder:"oat_…",mask:!0})}),G.error?R(f,{color:L.danger,children:G.error}):R(f,{color:L.faint,children:"⏎ sign in · Esc back"})]});if(G.kind==="password")return d(i1,{columns:Q,rows:B,status:G.field==="email"?"Your email":`Password for ${G.email}`,working:!1,children:[R(e,{borderStyle:"single",borderColor:L.focus,paddingX:1,width:Math.min(70,Q-4),children:R(p0,{state:G.state,width:Math.min(66,Q-8),placeholder:G.field==="email"?"you@company.com":"password",mask:G.field==="password"})}),G.error?R(f,{color:L.danger,wrap:"wrap",children:G.error}):d(f,{color:L.faint,children:["⏎ ",G.field==="email"?"next":"sign in"," · Esc back"]})]});if(G.kind==="saving")return R(i1,{columns:Q,rows:B,status:"Signing you in…"});return d(i1,{columns:Q,rows:B,status:"The sign-in didn't finish",working:!1,children:[R(e,{width:Math.min(80,Q-4),justifyContent:"center",children:R(f,{color:L.danger,wrap:"wrap",children:G.message})}),R(f,{color:L.faint,children:"⏎ try again"})]})}var MG,oZA,sQQ;var sZA=W(async()=>{Q5();IC();UJ();wQ();F1();oI();S0();RD();bB();HQ();await $0([dB(),gD(),tH()]);MG=pA(JQ(),1),oZA=[{id:"browser",label:"Sign in with your browser",detail:"Recommended: approve in the browser, then come back here"},{id:"device",label:"Sign in on another device",detail:"For SSH and machines without a browser: paste back the code Oatmilk shows"},{id:"key",label:"Paste an API key",detail:"Make one in Settings › Developer"},{id:"quit",label:"Quit",detail:""}],sQQ={id:"password",label:"Sign in with your password",detail:"Your account on this computer's Oatmilk; forgot it? oatmilk local password --reset"}});function tQQ(A,Q={}){let B=new URLSearchParams({organization:A});if(Q.tab)B.set("tab",Q.tab);if(Q.periodId)B.set("period",Q.periodId);else if(Q.date&&IN(Q.date))B.set("date",Q.date);if(Q.agreementId)B.set("agreement",Q.agreementId);if(Q.step)B.set("step",Q.step);if(Q.welcome)B.set("welcome","1");return`/contractor?${B}`}function eH(A,Q,B={}){return`${A}${tQQ(Q,B)}`}var sh=W(()=>{nP()});async function QBQ(A,Q,B){let E=await EB({host:A,organizationId:Q.organizationId});return{session:E,api:new k0(E,void 0,"contractor"),employer:Q,employers:B}}function tZA({host:A,employers:Q,columns:B,rows:E,onQuit:I}){let[D,J]=_I.useState(Q.length===1?Q[0]:null),[G,U]=_I.useState(null),[Y,H]=_I.useState(null),[X,N]=_I.useState(void 0),[z,F]=_I.useState(null),[V,O]=_I.useState(Q.length>1?{kind:"companies",index:0}:{kind:"view"}),[j,b]=_I.useState(TM),[x,v]=_I.useState(null);_I.useEffect(()=>{if(D||Q.length<=1)return;G4(A).then((YA)=>{let yA=Q.find((YQ)=>YQ.organizationId===YA.contractorOrganizationId);if(yA)J(yA),O({kind:"view"})})},[D,Q,A]),_I.useEffect(()=>{if(!D)return;let YA=!1;return QBQ(A,D,Q).then((yA)=>{if(!YA)U(yA)},(yA)=>{if(!YA)F(CQ(yA))}),()=>{YA=!0}},[A,D,Q]);let w=_I.useCallback(async(YA=X)=>{if(!G)return;try{H(await MJ(G,{periodId:YA})),F(null)}catch(yA){F(CQ(yA))}},[G,X]);_I.useEffect(()=>{if(!G)return;let YA=!1;return MJ(G,{periodId:X}).then((yA)=>{if(!YA)H(yA),F(null)},(yA)=>{if(!YA)F(CQ(yA))}),()=>{YA=!0}},[G,X]),_I.useEffect(()=>{if(!x)return;let YA=setTimeout(()=>v(null),x.tone==="danger"?7000:4000);return()=>clearTimeout(YA)},[x]);let k=_I.useMemo(()=>Y?zC(Y):[],[Y]),h=Y?.period.status==="paid"||Y?.period.status==="skipped",t=async(YA,yA,YQ,yQ=!1)=>{if(!G)return;O({kind:"log",step:2,minutes:yA,description:YQ,saving:!0});try{await a5(G,{date:YA,minutes:yA,description:YQ,confirmDuplicate:yQ}),O({kind:"view"}),b(TM),v({text:`${hA.done} Logged ${xE(yA)} on ${_J(YA)}`,tone:"success"}),await w()}catch(zQ){if(zQ instanceof mQ&&zQ.code==="DUPLICATE_ENTRY"&&!yQ){O({kind:"log",step:2,minutes:yA,description:YQ,duplicate:{date:YA}});return}O({kind:"log",step:2,minutes:yA,description:YQ,error:CQ(zQ)})}},i=async(YA)=>{if(!G||!Y)return;O({kind:"confirm",action:YA,busy:!0});try{if(YA==="send"){let yA=await JN(G,Y.period);H(yA.timesheet),v({text:`${hA.done} Sent ${yA.submitted.length} ${yA.submitted.length===1?"entry":"entries"} to ${G.employer.name} for review`,tone:"success"})}else await GN(G,Y.period),v({text:`${hA.done} ${G.employer.name} knows you had no hours this period`,tone:"success"}),await w()}catch(yA){v({text:yA instanceof mQ&&yA.code==="DETAILS_REQUIRED"?`${yA.message} Press o to add them in the portal.`:CQ(yA),tone:"danger"})}O({kind:"view"})},UA=()=>{if(!G)return;let YA=eH(G.session.host,G.employer.organizationId,{tab:"hours",...Y?.period.id?{periodId:Y.period.id}:{}});PE(YA).then((yA)=>v({text:yA?"Opened your portal in the browser":YA,tone:"info"}))},CA=(YA)=>{if(!Y?.periods.length)return;let yA=[...Y.periods].sort((zQ,uA)=>zQ.periodStart.localeCompare(uA.periodStart)),YQ=yA.findIndex((zQ)=>zQ.periodStart===Y.period.periodStart),yQ=yA[YQ+YA];if(!yQ?.id)return;N(yQ.id),H(null)};iQ((YA,yA)=>{if(yA.ctrl&&YA==="c"){I();return}if(V.kind==="companies"){if(yA.upArrow||YA==="k")O({kind:"companies",index:Math.max(0,V.index-1)});else if(yA.downArrow||YA==="j")O({kind:"companies",index:Math.min(Q.length-1,V.index+1)});else if(yA.return){let YQ=Q[V.index];if(YQ.organizationId!==D?.organizationId)U(null),H(null);J(YQ),N(void 0),O({kind:"view"}),DN(A,YQ)}else if(yA.escape&&D)O({kind:"view"});else if(YA==="q")I();return}if(V.kind==="confirm"){if(V.busy)return;if(YA==="y"||yA.return)i(V.action);else if(YA==="n"||yA.escape)O({kind:"view"});return}if(V.kind==="log"){if(V.saving)return;if(V.duplicate){if(YA==="y")t(V.duplicate.date,V.minutes,V.description,!0);else if(YA==="n"||yA.escape)O({kind:"view"});return}if(yA.escape){if(V.step===0){O({kind:"view"}),b(TM);return}let yQ=V.step-1;b(th(yQ===0?xE(V.minutes??0):V.description??"")),O({...V,step:yQ,error:void 0});return}let YQ=BI(j,YA,yA,2000);if(YQ.type==="edit"){b(YQ.state);return}if(YQ.type!=="submit")return;try{if(V.step===0){let yQ=CN(j.value);O({kind:"log",step:1,minutes:yQ}),b(th(V.description??""))}else if(V.step===1){let yQ=j.value.trim();if(!yQ){O({...V,error:"Say what you did."});return}O({kind:"log",step:2,minutes:V.minutes,description:yQ}),b(th("today"))}else t(VJ(j.value||"today"),V.minutes,V.description)}catch(yQ){O({...V,error:CQ(yQ)})}return}if(YA==="q")I();else if(!Y)return;else if((YA==="a"||yA.return)&&!h)b(TM),O({kind:"log",step:0});else if(YA==="s"&&k.length&&!h)O({kind:"confirm",action:"send"});else if(YA==="n"&&!Y.entries.length&&!Y.period.noHoursReportedAt&&Y.period.id&&!h)O({kind:"confirm",action:"none"});else if(YA==="[")CA(-1);else if(YA==="]")CA(1);else if(YA==="c"&&Q.length>1)O({kind:"companies",index:Math.max(0,Q.findIndex((YQ)=>YQ.organizationId===D?.organizationId))});else if(YA==="o")UA();else if(YA==="r")w()});let GA=Math.max(30,Math.min(B-4,100)),iA=d(e,{width:GA,marginBottom:1,children:[d(f,{bold:!0,color:L.accent,children:[hA.brand," oatmilk"]}),R(f,{color:L.muted,children:` ${D?.name??"Your hours"} ${hA.dot} contractor`})]}),jA=(YA,yA)=>d(e,{width:B,height:E,flexDirection:"column",alignItems:"center",paddingTop:1,children:[iA,R(e,{flexDirection:"column",width:GA,flexGrow:1,children:YA}),d(e,{width:GA,flexDirection:"column",children:[x?R(f,{color:x.tone==="success"?L.success:x.tone==="danger"?L.danger:L.info,wrap:"wrap",children:x.text}):null,R(f,{color:L.faint,wrap:"truncate-end",children:yA})]})]});if(V.kind==="companies")return jA(d(PB,{children:[R(f,{bold:!0,children:"Which company are these hours for?"}),R(e,{flexDirection:"column",marginTop:1,children:Q.map((YA,yA)=>d(f,{color:yA===V.index?L.focus:L.text,bold:yA===V.index,children:[yA===V.index?`${hA.pointer} `:" ",YA.name]},YA.organizationId))})]}),`↑↓ choose · ⏎ open${D?" · Esc back":""} · q quit`);if(z&&!Y)return jA(R(f,{color:L.danger,wrap:"wrap",children:z}),"r try again · o portal · q quit");if(!Y)return jA(d(PB,{children:[R(f,{color:L.muted,children:"Your hours"}),R(e,{marginTop:1,children:R(zE,{rows:4,width:GA,columns:[12,7,Math.max(10,GA-44),14],label:"Opening your hours"})})]}),"q quit");if(V.kind==="log"){let YA=V.duplicate?`You already logged "${V.description}" on ${_J(V.duplicate.date)}. Keep both?`:eQQ[V.step];return jA(d(PB,{children:[R(f,{color:L.muted,children:`${V.step+1}/3`}),R(f,{bold:!0,wrap:"wrap",children:YA}),V.duplicate?null:R(e,{marginTop:1,borderStyle:"single",borderColor:L.focus,paddingX:1,children:R(p0,{state:j,width:GA-4,placeholder:ABQ[V.step]})}),V.saving?R(f0,{label:"Saving…"}):V.error?R(f,{color:L.danger,wrap:"wrap",children:V.error}):null]}),V.duplicate?"y keep both · n don't":V.step===2?"⏎ log it · Esc back":"⏎ next · Esc back")}if(V.kind==="confirm"){let YA=V.action==="send"?`Send ${k.length} ${k.length===1?"entry":"entries"} (${xE(qC(k))}) to ${D?.name} for review?`:`Tell ${D?.name} you had no hours ${C9(Y.period).split(` ${hA.dot} `)[0]}?`;return jA(d(PB,{children:[R(f,{bold:!0,wrap:"wrap",children:YA}),V.busy?R(e,{marginTop:1,children:R(f0,{label:"Sending…"})}):null]}),"y yes · n no")}let IQ=[...Y.entries].sort((YA,yA)=>YA.date.localeCompare(yA.date)),_A=Math.max(10,GA-44),RB=h?null:k.length?`s Send ${k.length===1?"it":`these ${k.length}`} for review`:"a Log time";return jA(d(PB,{children:[R(f,{bold:!0,wrap:"truncate-end",children:C9(Y.period)}),d(e,{flexDirection:"column",marginTop:1,children:[IQ.length?IQ.map((YA)=>d(f,{wrap:"truncate-end",children:[uI(_J(YA.date),12)," ",uI(xE(YA.minutes),7,"right")," ",uI(YA.description,_A)," ",R(f,{color:YA.status==="rejected"?L.danger:YA.status==="approved"?L.success:YA.status==="draft"?L.warning:L.muted,children:o5(YA)})]},YA.id)):R(f,{color:L.muted,children:Y.period.noHoursReportedAt?"You said you had no hours this period.":"No hours logged yet."}),IQ.length?R(f,{color:L.muted,children:`${xE(qC(IQ))} in all${k.length?` ${hA.dot} ${k.length} not sent yet`:""}`}):null]}),RB?R(e,{marginTop:1,children:d(f,{bold:!0,color:L.focus,children:[hA.pointer," ",RB]})}):null,k.some((YA)=>YA.missing?.length)?R(f,{color:L.warning,wrap:"wrap",children:"Some entries need more details in the portal (press o)."}):null]}),["a log time",k.length&&!h?"s send":null,!Y.entries.length&&Y.period.id&&!h?"n no hours":null,"[ ] period",Q.length>1?"c company":null,"o portal","q quit"].filter(Boolean).join(` ${hA.dot} `))}var _I,eQQ,ABQ,TM,th=(A)=>({value:A,cursor:A.length});var eZA=W(async()=>{sh();SE();UJ();$9();wQ();d1();oI();S0();RD();bB();HQ();await $0([dB(),gD(),FG(),vD()]);_I=pA(JQ(),1),eQQ=["How long did you work?","What did you do?","Which day?"],ABQ=["2h, 1h30m or 1:30","Design review","today, yesterday, mon or 2026-10-06"],TM={value:"",cursor:0}});function PM({percent:A,label:Q=!0}){let B=Math.max(0,Math.min(100,Math.round(A)));return d(f,{children:[d(f,{bold:!0,color:B>=75?L.success:B>0?L.text:L.muted,children:[B,"% local"]}),Q?R(f,{color:L.muted,children:` · ${LK(B)}`}):null]})}var eh=W(async()=>{Z4();bB();HQ();await dB()});function IBQ(A,Q,B,E){if(!A||A==="cloud"||A==="remote"||A==="more")return[];let I=A==="custom"?["parts"]:[];if(E)I.push("servers","models");for(let D=0;D<B;D+=1)I.push(`cloud:${D}`);if(Q.account==="local")for(let D=0;D<B2.length;D+=1)I.push(`account:${D}`);return I.push("review"),I}function EBQ(A){if(A.kind==="server-url")return"servers";if(A.kind==="cloud"||A.kind==="account")return`${A.kind}:${A.index}`;return A.kind}function DBQ(A,Q){let B=A.indexOf(Q);return B<0?null:{current:B+1,total:A.length}}function A3A(A,Q){if(Q==="chat")return A.chat;if(Q==="vision")return A.vision??A.chat;if(Q==="classifier")return A.classifier??A.chat;return A.embedding}function JBQ(A,Q,B,E){if(Q==="chat")return{...A,chat:B??A.chat};if(Q==="vision")return{...A,vision:B&&B!==A.chat?B:void 0};if(Q==="classifier")return{...A,classifier:B&&B!==A.chat?B:void 0,classifierApi:B&&/^(tev1|nimble)(:|$)/.test(B)&&E.decisionModels?"systemone":"chat"};return{...A,embedding:B}}function GBQ(A,Q,B){let E=bJ(A.kind,{decisionModels:A.decisionModels,memoryBytes:B}),I=Q==="chat"?E.chat:Q==="vision"?E.vision:Q==="classifier"?E.classifier:E.embedding,D=A.models.filter((J)=>Q==="embedding"?J.capabilities.includes("embedding")||/embed/i.test(J.id):!J.capabilities.includes("embedding")||J.capabilities.includes("completion")).map((J)=>J.id);return[...new Set([...D,...lE(A,I)?[]:[I]])]}function Q3A({columns:A,rows:Q,previous:B,onDone:E,onQuit:I,deps:D={}}){let[J,G]=jB.useState({kind:"welcome"}),U=jB.useRef([]),[Y,H]=jB.useState(0),[X,N]=jB.useState(B?.mode==="local"?B.placements:{...$8}),[z,F]=jB.useState(B?.runtime?.kind??"docker"),[V,O]=jB.useState(null),[j,b]=jB.useState(null),[x,v]=jB.useState({}),[w,k]=jB.useState(null),[h,t]=jB.useState(B?.models??null),[i,UA]=jB.useState(null),[CA,GA]=jB.useState({}),[iA,jA]=jB.useState(A2),IQ=Kz(),[_A,RB]=jB.useState({name:[B?.account?.firstName??IQ.firstName,B?.account?.lastName].filter(Boolean).join(" "),email:B?.account?.email??IQ.email,company:B?.account?.company??"",password:""}),[YA,yA]=jB.useState(null),[YQ,yQ]=jB.useState(!1);jB.useEffect(()=>{sQ().then((p)=>yQ(!!p.hosts[t0]?.credential),()=>{return})},[]);let[zQ,uA]=jB.useState({}),[sA,qQ]=jB.useState(""),[YB]=jB.useState(()=>{try{return(D.source??(()=>kC({remembered:B?.runtime?.sourceDir})))()}catch{return null}}),tA=jB.useRef(null);jB.useEffect(()=>()=>tA.current?.abort(),[]);let WQ=jB.useCallback((p,IA={})=>{G((SA)=>{if(!IA.replace)U.current.push(SA);return p}),H(0)},[]),EQ=jB.useCallback(()=>{let p=U.current.pop();if(p)G(p),H(0)},[]),AB=Uz(X,z),fB=jB.useRef(null),B0=jB.useCallback((p=!1)=>{let IA=(D.detect??(()=>p4()))().catch(()=>[]);fB.current=IA,IA.then((SA)=>{O(SA),v(Object.fromEntries(SA.filter((TA)=>!TA.running).map((TA)=>[TA.kind,(D.canStart??j9)(TA.kind)])));let mA=SA.findIndex((TA)=>TA.running&&TA.server);if(p&&mA>0)H(mA)})},[D]),i0=jB.useCallback(()=>{O(null),B0(!0)},[B0]);jB.useEffect(()=>{B0()},[B0]);let rQ=()=>WQ({kind:"review"}),hB=()=>{if(X.account==="local")jA(Q2(_A.name)),WQ({kind:"account",index:0});else rQ()},MB=()=>{if(AB.length)jA(A2),WQ({kind:"cloud",index:0});else hB()},KB=(p=X)=>{if(cE(p))i0(),WQ({kind:"servers"});else if(Uz(p,z).length)jA(A2),WQ({kind:"cloud",index:0});else if(p.account==="local")jA(Q2(_A.name)),WQ({kind:"account",index:0});else WQ({kind:"review"})},X0=async(p)=>{await Y8({mode:"cloud",host:t0,placements:{...SJ}});let IA=await sQ();IA.defaultHost=t0,IA.preferences={...IA.preferences,askAi:p??IA.preferences?.askAi??{kind:"oatmilk"}},await FI(IA),E({host:t0,mode:"cloud",signedIn:!1})},v0=async(p,IA=!1)=>{if(yA(p),p==="more"){WQ({kind:"more"});return}if(!IA&&p==="cloud"&&B?.mode==="local"){WQ({kind:"move-note",target:"cloud",next:p});return}if(!IA&&["local","local-ai","custom"].includes(p)&&(B?.mode==="cloud"||YQ)){WQ({kind:"move-note",target:"local",next:p});return}if(p==="cloud"){let TA=(await(fB.current??Promise.resolve(V??[]))).map((eA)=>eA.running&&eA.server?{server:eA.server,model:vIA(eA.server.models)}:null).find((eA)=>eA?.model);if(TA?.model){WQ({kind:"ai-here",server:TA.server,model:TA.model});return}await X0();return}if(p==="remote"){jA(Q2("http://localhost:3000")),WQ({kind:"remote"});return}if(p==="custom"){WQ({kind:"parts"});return}let SA={...[...Au,...Qu].find((mA)=>mA.id===p).placements};if(N(SA),p==="local-ai"&&YB&&!Yz(YB).length)F("source");KB(SA)},nB=async(p)=>{let IA=kJ(p);k(p);let SA=B?.models?.server===p.kind&&B.models.baseUrl===p.baseUrl?B.models:null;t(SA??IA.models),UA(null),WQ({kind:"models"})},j0=()=>{let p={...X};for(let SA of wC)if(p[SA]==="local")p[SA]="cloud";if(N(p),Uz(p,z).length)jA(A2),WQ({kind:"cloud",index:0});else hB()},SQ=()=>{tA.current?.abort();let p=new AbortController;tA.current=p,uA({}),qQ(""),WQ({kind:"installing"},{replace:J.kind==="failed"});let[IA,...SA]=_A.name.trim().split(/\s+/),mA={choices:{placements:X,runtime:z,models:cE(X)?h??void 0:void 0,cloud:CA},sourceDir:YB??void 0,download:!0,pullModels:!0,account:X.account==="local"?{email:_A.email.trim().toLowerCase(),firstName:IA||"Me",lastName:SA.join(" ")||void 0,company:_A.company.trim(),password:_A.password||void 0}:void 0},TA={onStep:(eA)=>{if(!p.signal.aborted)uA((NB)=>({...NB,[eA.step]:eA}))},onLine:(eA,NB)=>{if(!p.signal.aborted)qQ(NB)}};(D.install??((eA,NB)=>Fz(eA,NB,{signal:p.signal})))(mA,TA).then((eA)=>{if(!p.signal.aborted)G({kind:"done",result:eA})},(eA)=>{if(!p.signal.aborted)G({kind:"failed",message:CQ(eA),hint:eA instanceof n?eA.hint:void 0})})},gB=async(p)=>{let IA;try{IA=q1(p)}catch(TA){G({kind:"remote",error:CQ(TA)});return}if(G({kind:"remote",checking:!0}),!await(D.health??n4)(IA)){G({kind:"remote",error:`Nothing answers as Oatmilk at ${IA}. Is it running?`});return}await Y8({mode:"remote",host:IA,placements:{...SJ}});let mA=await sQ();mA.defaultHost=IA,await FI(mA),E({host:IA,mode:"remote",signedIn:!!mA.hosts[IA]?.credential})},h0=(p)=>{let IA=AB[p],SA=iA.value.trim();if(!SA&&!IA.optional&&B?.mode!=="local"){G({kind:"cloud",index:p,error:`Enter the ${IA.label.split(" (")[0]}.`});return}let mA=SA?OIA(CA,IA.key,SA):CA;if(GA(IA.key==="s3.endpoint"&&SA?{...mA,s3:{...mA.s3,forcePathStyle:!0}}:mA),jA(A2),p+1<AB.length)WQ({kind:"cloud",index:p+1});else hB()},LI=(p)=>{let IA=B2[p],SA=iA.value.trim();if(IA==="name"&&!SA){G({kind:"account",index:p,error:"Enter your name."});return}if(IA==="company"&&(SA.length<2||SA.length>100)){G({kind:"account",index:p,error:"Enter your company's name (2 to 100 characters)."});return}let mA={..._A,[IA]:SA};if(RB(mA),p+1<B2.length)jA(Q2(mA[B2[p+1]])),WQ({kind:"account",index:p+1});else rQ()},Z0=WK(X,z),cI=fI.length+1,G0=[...(V??[]).map((p)=>({kind:"probe",probe:p})),{kind:"url"},{kind:"cloud"}],KI=w&&h?vC(w,h):[],n0=w?.kind!=="ollama"?KI:[];iQ((p,IA)=>{let SA=IA.upArrow||p==="k",mA=IA.downArrow||p==="j";if(J.kind==="welcome"||J.kind==="more"){let TA=J.kind==="welcome"?Au:Qu;if(SA)H((eA)=>Math.max(0,eA-1));else if(mA)H((eA)=>Math.min(TA.length-1,eA+1));else if(/^[1-9]$/.test(p)&&Number(p)<=TA.length)v0(TA[Number(p)-1].id);else if(IA.return)v0(TA[Y].id);else if(J.kind==="more"&&IA.escape)EQ();else if(p==="q"||IA.escape)I();return}if(J.kind==="move-note"){if(IA.return)v0(J.next,!0);else if(IA.escape)EQ();return}if(J.kind==="ai-here"){if(SA||mA)H((TA)=>TA===0?1:0);else if(IA.return||p==="y"||p==="n"){let TA=p==="y"||IA.return&&Y===0;X0(TA?{kind:"local",server:J.server.kind,baseUrl:J.server.baseUrl,model:J.model}:{kind:"oatmilk"})}else if(IA.escape)EQ();return}if(J.kind==="parts"){if(SA)H((TA)=>Math.max(0,TA-1));else if(mA)H((TA)=>Math.min(cI-1,TA+1));else if(IA.leftArrow||IA.rightArrow||p===" "||p==="h"||p==="l"){let TA=IA.leftArrow||p==="h"?-1:1;if(Y===fI.length)F((eA)=>eA==="docker"?"source":"docker");else{let eA=fI[Y];N((NB)=>({...NB,[eA.id]:lw(eA.id,NB[eA.id],TA)}))}}else if(IA.return&&!Z0.length)KB();else if(IA.escape)EQ();return}if(J.kind==="remote"||J.kind==="server-url"||J.kind==="cloud"||J.kind==="account"){if(IA.escape){EQ();return}if(J.kind==="remote"&&J.checking)return;let TA=J.kind==="cloud"?4000:300,eA=BI(iA,p,IA,TA);if(eA.type==="edit"){jA(eA.state);return}if(eA.type!=="submit")return;if(J.kind==="remote")gB(iA.value);else if(J.kind==="cloud")h0(J.index);else if(J.kind==="account")LI(J.index);else{let NB;try{NB=vJ(iA.value)}catch(n1){G({kind:"server-url",error:CQ(n1)});return}(D.inspect??hI)("openai-compatible",NB).then((n1)=>nB(n1),()=>G({kind:"server-url",error:`Nothing answers with the OpenAI API at ${NB}.`}))}return}if(J.kind==="servers"){if(p==="r"){i0();return}let TA=G0[Y];if(p==="s"&&V&&TA?.kind==="probe"&&!TA.probe.running&&!j&&x[TA.probe.kind]){let eA=TA.probe.kind;b({kind:eA}),(D.startServer??((NB)=>R9(NB,{listenAll:z==="docker"&&process.platform==="linux"})))(eA).then((NB)=>{if(b(NB?null:{kind:eA,failed:!0}),NB)i0()},()=>b({kind:eA,failed:!0}));return}if(IA.escape){EQ();return}if(!V)return;if(SA)H((eA)=>Math.max(0,eA-1));else if(mA)H((eA)=>Math.min(G0.length-1,eA+1));else if(IA.return){let eA=G0[Y];if(eA.kind==="url")jA(Q2("http://localhost:8000/v1")),WQ({kind:"server-url"});else if(eA.kind==="cloud")j0();else if(eA.probe.server)nB(eA.probe.server)}return}if(J.kind==="models"&&w&&h){if(SA)H((TA)=>Math.max(0,TA-1));else if(mA)H((TA)=>Math.min(SM.length-1,TA+1));else if(IA.leftArrow||IA.rightArrow||p==="h"||p==="l"){let TA=SM[Y],eA=GBQ(w,TA.id),NB=TA.id==="embedding"?[void 0,...eA]:eA,n1=NB.indexOf(A3A(h,TA.id)),j$=NB[(n1+(IA.leftArrow||p==="h"?-1:1)+NB.length)%NB.length];t(JBQ(h,TA.id,j$,w))}else if(p==="t")UA(`Asking ${h.chat}… (the first answer loads it into memory)`),(D.check??Xz)(w.baseUrl,h.chat).then((TA)=>UA(TA.ok?`${hA.done} ${h.chat} answered in ${(TA.ms/1000).toFixed(1)} s`:`${hA.failed} ${TA.problem??"No answer"}`));else if(p==="r")(D.inspect??hI)(w.kind,w.baseUrl).then((TA)=>k(TA),()=>{return});else if(IA.return&&!n0.length)MB();else if(IA.escape)EQ();return}if(J.kind==="review"){if(IA.return)SQ();else if(p==="e")WQ({kind:"parts"});else if(IA.escape)EQ();return}if(J.kind==="failed"){if(p==="r"||IA.return)SQ();else if(IA.escape)G({kind:"review"});else if(p==="q")I();return}if(J.kind==="done"&&IA.return)E({host:J.result.host,mode:"local",signedIn:J.result.signedIn})});let bA=Math.max(30,Math.min(A-4,92)),BA=["parts","review","installing","failed"].includes(J.kind),XA=d(e,{flexDirection:"column",alignItems:"center",marginBottom:1,children:[Q>=30?R(rh,{columns:A,animate:!1}):d(f,{bold:!0,color:L.accent,children:[hA.brand," oatmilk"]}),BA?R(e,{marginTop:1,children:R(PM,{percent:U8(X)})}):null]}),$Q=DBQ(IBQ(YA,X,AB.length,cE(X)),EBQ(J)),kQ=(p,IA,SA)=>d(e,{width:A,height:Q,flexDirection:"column",alignItems:"center",justifyContent:"center",children:[XA,d(e,{flexDirection:"column",width:bA,children:[$Q?R(f,{color:L.muted,children:`${$Q.current}/${$Q.total}`}):null,R(f,{bold:!0,wrap:"wrap",children:p}),R(e,{flexDirection:"column",marginTop:1,children:IA}),R(e,{marginTop:1,children:R(f,{color:L.faint,wrap:"truncate-end",children:SA})})]})]});if(J.kind==="welcome"||J.kind==="more"){let p=J.kind==="welcome"?Au:Qu,IA=p[Math.min(Y,p.length-1)];return kQ(J.kind==="welcome"?"Welcome to Oatmilk. How do you want to use it?":"More ways to run Oatmilk",d(PB,{children:[p.map((SA,mA)=>d(f,{color:mA===Y?L.focus:SA.id==="more"?L.muted:L.text,bold:mA===Y,wrap:"truncate-end",children:[mA===Y?`${hA.pointer} `:" ",SA.label]},SA.id)),R(e,{marginTop:1,children:R(f,{color:L.muted,wrap:"wrap",children:IA.detail})})]}),J.kind==="welcome"?"↑↓ choose · ⏎ continue · q quit":"↑↓ choose · ⏎ continue · Esc back")}if(J.kind==="move-note"){let p=J.target==="cloud";return kQ(p?"Your books on this computer stay here":"Your books in Oatmilk Cloud stay there",d(e,{flexDirection:"column",children:[R(f,{wrap:"wrap",children:p?"Oatmilk Cloud has its own books, and nothing on this computer moves there by itself.":"This makes a new Oatmilk on this computer, and nothing in Oatmilk Cloud moves here by itself."}),R(e,{marginTop:1,children:R(f,{color:L.muted,wrap:"wrap",children:p?"Keep a copy first with oatmilk export --local. The Oatmilk here keeps running until you stop it with oatmilk local stop, and oatmilk --local still opens it.":"Keep a copy first with oatmilk export --cloud. Your cloud account stays signed in, and oatmilk --cloud still opens it."})})]}),"⏎ continue · Esc back")}if(J.kind==="ai-here"){let p=pB[J.server.kind];return kQ("Use the AI on this computer?",d(PB,{children:[R(e,{children:R(f,{color:L.muted,wrap:"wrap",children:`${p} is running here with ${J.model}. Ask AI in the terminal can use it: your books stay in Oatmilk, and your questions and answers stay on this computer.`})}),R(e,{marginTop:1,flexDirection:"column",children:[`Yes, use ${J.model}`,"No, use Oatmilk's AI"].map((IA,SA)=>d(f,{color:SA===Y?L.focus:L.text,bold:SA===Y,children:[SA===Y?`${hA.pointer} `:" ",IA]},IA))})]}),"↑↓ choose · ⏎ continue · Esc back · change it any time with /model")}if(J.kind==="parts"){let IA=fI[Y];return kQ("Where should each part run? Oatmilk itself runs on this computer.",d(PB,{children:[fI.map((SA,mA)=>{let TA=X[SA.id],eA=TA==="local"?L.success:TA==="cloud"?L.warning:L.muted;return d(f,{wrap:"truncate-end",color:mA===Y?L.focus:L.text,children:[mA===Y?`${hA.pointer} `:" ",SA.label.padEnd(20),R(f,{color:eA,children:`‹ ${wJ(TA)} ›`.padEnd(18)}),R(f,{color:L.muted,children:SA.about})]},SA.id)}),d(f,{wrap:"truncate-end",color:Y===fI.length?L.focus:L.text,children:[Y===fI.length?`${hA.pointer} `:" ","How it runs".padEnd(20),R(f,{color:L.info,children:`‹ ${z==="docker"?"Docker":"From source"} ›`.padEnd(18)}),R(f,{color:L.muted,children:z==="docker"?"recommended: the full app in containers":"bun run dev in your checkout"})]}),R(e,{marginTop:1,children:R(f,{color:Z0.length?L.danger:L.muted,wrap:"wrap",children:Z0[0]??(Y<fI.length?IA.options[X[IA.id]]:z==="docker"?"Docker builds and runs Oatmilk with its database and file storage. The first build takes about 10 minutes.":"Runs bun run dev from your Oatmilk checkout, with hot reload. For people working on Oatmilk.")})})]}),"↑↓ choose · ←→ change · ⏎ continue · Esc back")}if(J.kind==="remote")return kQ("Which Oatmilk should the terminal use?",d(PB,{children:[R(e,{borderStyle:"single",borderColor:L.focus,paddingX:1,children:R(p0,{state:iA,width:bA-4,placeholder:"https://books.example.com"})}),J.checking?R(f0,{label:"Checking it answers…"}):J.error?R(f,{color:L.danger,wrap:"wrap",children:J.error}):R(f,{color:L.muted,children:"A self-hosted Oatmilk, or http://localhost:3000 for bun run dev."})]}),"⏎ connect · Esc back");if(J.kind==="servers")return kQ("Which model server should run Oatmilk's AI?",!V?R(f0,{label:"Looking for Ollama and LM Studio on this computer…"}):d(PB,{children:[G0.map((p,IA)=>{let SA=IA===Y,mA=SA?`${hA.pointer} `:" ";if(p.kind==="url")return d(f,{color:SA?L.focus:L.text,children:[mA,"Another server (vLLM, llama.cpp, LocalAI…)"]},"url");if(p.kind==="cloud")return d(f,{color:SA?L.focus:L.text,children:[mA,"Use cloud models instead ",R(f,{color:L.muted,children:"(Vercel AI Gateway)"})]},"cloud");let{probe:TA}=p;return d(f,{color:SA?L.focus:TA.running?L.text:L.muted,wrap:"truncate-end",children:[mA,R(f,{color:TA.running?L.success:L.faint,children:TA.running?"●":"○"})," ",TA.label,TA.server?.version?` ${TA.server.version}`:""," ",R(f,{color:L.muted,children:TA.running?`${TA.server?.models.length??0} models · ${TA.baseUrl}`:"not running"})]},TA.kind)}),(()=>{let p=G0[Y];if(p?.kind==="probe"&&j?.kind===p.probe.kind&&!j.failed)return R(e,{marginTop:1,children:R(f0,{label:`Starting ${p.probe.label}…`})});if(p?.kind==="probe"&&!p.probe.running)return R(e,{marginTop:1,children:d(f,{color:L.warning,wrap:"wrap",children:[j?.kind===p.probe.kind?`${p.probe.label} didn't start. `:"",x[p.probe.kind]?`Press s to start ${p.probe.label} now${p.probe.kind==="ollama"?" (with a context long enough for statements)":""}, or start it yourself and press r.`:`${tI(p.probe.kind)} Then press r.`]})});if(p?.kind==="probe"&&p.probe.server&&!p.probe.server.models.length)return R(e,{marginTop:1,children:d(f,{color:L.muted,wrap:"wrap",children:["No models yet: Oatmilk ",p.probe.kind==="ollama"?"downloads the recommended ones during setup":`needs one first: ${pE(p.probe.kind,bJ(p.probe.kind).chat)}`,"."]})});return null})()]}),"↑↓ choose · ⏎ continue · s start it · r look again · Esc back");if(J.kind==="server-url")return kQ("Your server's OpenAI-compatible address",d(PB,{children:[R(e,{borderStyle:"single",borderColor:L.focus,paddingX:1,children:R(p0,{state:iA,width:bA-4,placeholder:"http://localhost:8000/v1"})}),J.error?R(f,{color:L.danger,wrap:"wrap",children:J.error}):R(f,{color:L.muted,children:"It must answer /v1/models and /v1/chat/completions."})]}),"⏎ continue · Esc back");if(J.kind==="models"&&w&&h){let p=SM[Y];return kQ(`Models on ${pB[w.kind]}`,d(PB,{children:[SM.map((IA,SA)=>{let mA=A3A(h,IA.id),TA=X[IA.part]==="local",eA=mA?!!lE(w,mA):!0,NB=!TA?"in the cloud":!mA?"off":eA?"installed":w.kind==="ollama"?"downloads during setup":"not on the server";return d(f,{wrap:"truncate-end",color:SA===Y?L.focus:TA?L.text:L.muted,children:[SA===Y?`${hA.pointer} `:" ",IA.label.padEnd(20),R(f,{children:`‹ ${mA??"none"} ›`.padEnd(30)}),R(f,{color:!TA?L.faint:eA?L.success:w.kind==="ollama"?L.warning:L.danger,children:NB})]},IA.id)}),d(e,{marginTop:1,flexDirection:"column",children:[n0.length?d(f,{color:L.danger,wrap:"wrap",children:["Download first: ",n0.map((IA)=>pE(w.kind,IA)).join(" · "),", then press r."]}):null,i?R(f,{color:i.startsWith(hA.failed)?L.danger:L.muted,wrap:"wrap",children:i}):R(f,{color:L.muted,wrap:"wrap",children:p.id==="classifier"?h.classifierApi==="systemone"?"A decision model answers classifiers with calibrated confidence, like TypeSafe's Jev.":"A chat model answers classifiers as structured JSON. Steps that need confidence, like matching receipts, wait for you.":p.id==="vision"?"Reads receipts, statements and PDFs. Pick a model that sees images.":p.id==="embedding"?"Optional: ranks search results.":"Answers Ask AI and runs the agents. Pick one that calls tools."})]})]}),"↑↓ choose · ←→ change model · t test · r refresh · ⏎ continue · Esc back")}if(J.kind==="cloud"){let p=AB[J.index];if(!p)return kQ("",null,"");return kQ(`${p.label}`,d(PB,{children:[R(e,{borderStyle:"single",borderColor:L.focus,paddingX:1,children:R(p0,{state:iA,width:bA-4,mask:p.secret,placeholder:p.optional?"optional":B?.mode==="local"?"empty keeps the saved one":""})}),J.error?R(f,{color:L.danger,children:J.error}):R(f,{color:L.muted,children:"Kept only in the local Oatmilk's settings file."})]}),"⏎ next · Esc back")}if(J.kind==="account"){let p=B2[J.index];return kQ(BBQ[p],d(PB,{children:[R(e,{borderStyle:"single",borderColor:L.focus,paddingX:1,children:R(p0,{state:iA,width:bA-4,placeholder:p==="company"?"Acme Inc.":""})}),J.error?R(f,{color:L.danger,children:J.error}):R(f,{color:L.muted,children:"Nothing here leaves this computer."})]}),"⏎ next · Esc back")}if(J.kind==="review")return kQ("Ready to set up",d(PB,{children:[fI.map((p)=>{let IA=X[p.id];return d(f,{wrap:"truncate-end",children:[" ",p.label.padEnd(20),R(f,{color:IA==="local"?L.success:IA==="cloud"?L.warning:L.muted,children:wJ(IA).padEnd(16)}),R(f,{color:L.muted,children:p.options[IA]})]},p.id)}),d(e,{marginTop:1,flexDirection:"column",children:[d(f,{color:L.muted,wrap:"wrap",children:["Runs ",z==="docker"?"in Docker at https://oatmilk.localhost (the first build takes about 10 minutes)":"from source with bun run dev at http://localhost:3000",YB?` from ${YB}`:", from a copy of Oatmilk's source the CLI downloads","."]}),cE(X)&&h?d(f,{color:L.muted,wrap:"truncate-end",children:["Models: ",pB[h.server]," · ",[h.chat,h.classifier,h.vision].filter(Boolean).join(" · ")]}):null,X.account==="local"?d(f,{color:L.muted,wrap:"truncate-end",children:["You: ",_A.name," · ",_A.company," · signed in here as ",_A.email]}):R(f,{color:L.muted,children:"You sign in with your cloud account once it's running."}),RK(B,X)?R(e,{marginTop:1,children:R(f,{color:L.warning,wrap:"wrap",children:"Your books and files don't move to their new place by themselves. Back them up first with oatmilk local backup."})}):null]})]}),"⏎ set up · e change parts · Esc back");if(J.kind==="installing"||J.kind==="failed"){let p=["tools","source","models","settings","packages","start","ready","reach","account","signin","company"];return kQ(J.kind==="failed"?"Setup stopped":"Setting up Oatmilk on this computer",d(PB,{children:[p.map((IA)=>{let SA=zQ[IA],mA=!SA?R(f,{color:L.faint,children:hA.pending}):SA.status==="running"?R(f0,{}):SA.status==="done"?R(f,{color:L.success,children:hA.done}):SA.status==="skipped"?R(f,{color:L.faint,children:"–"}):SA.status==="warning"?R(f,{color:L.warning,children:"!"}):R(f,{color:L.danger,children:hA.failed});return d(e,{gap:1,children:[mA,d(f,{color:SA?L.text:L.muted,wrap:"truncate-end",children:[qz[IA],SA?.detail&&SA.status!=="failed"&&SA.status!=="warning"?R(f,{color:L.muted,children:` ${SA.detail}`}):null]})]},IA)}),R(e,{marginTop:1,flexDirection:"column",children:J.kind==="failed"?d(PB,{children:[R(f,{color:L.danger,wrap:"wrap",children:J.message}),J.hint?R(f,{color:L.muted,wrap:"wrap",children:J.hint}):null]}):R(f,{color:L.faint,wrap:"truncate-end",children:sA||" "})})]}),J.kind==="failed"?"r try again · Esc change choices · q quit":"Keep this open; ⌃C stops setup")}if(J.kind!=="done")return kQ("Your models",R(f0,{label:"Reading the model server…"}),"Esc back");let gA=J.result;return kQ("Oatmilk is ready",d(PB,{children:[d(f,{children:[R(f,{color:L.success,children:hA.done})," Running at ",R(f,{bold:!0,children:gA.host})]}),gA.signedIn?d(f,{children:[R(f,{color:L.success,children:hA.done})," Signed in as ",_A.email,_A.company?` · ${_A.company}`:""]}):R(f,{color:L.muted,children:"Next: sign in with your cloud account."}),gA.warnings.map((p)=>d(f,{color:L.warning,wrap:"wrap",children:["! ",p]},p)),gA.generatedPassword?d(f,{color:L.muted,wrap:"wrap",children:["For the browser, sign in as ",_A.email," with ",R(f,{color:L.text,children:gA.generatedPassword})," (see it again: oatmilk local password)."]}):null,R(f,{color:L.muted,wrap:"wrap",children:"Manage it with oatmilk local, the models with oatmilk models, and see the gauge with oatmilk status."})]}),`⏎ open ${TI(gA.host)}`)}var jB,Au,Qu,SM,B2,BBQ,A2,Q2=(A)=>({value:A,cursor:A.length});var B3A=W(async()=>{wQ();F1();S0();fJ();Mz();xJ();TK();Z4();K8();RD();bB();HQ();await $0([dB(),gD(),eh(),tH(),vD()]);jB=pA(JQ(),1),Au=[{id:"cloud",label:"Sign in to Oatmilk",detail:"Use your account at getoatmilk.com, or make one. Nothing to install.",placements:SJ},{id:"local",label:"Keep everything on this computer",detail:"Your books, files and AI stay here, with no account to make. It needs Docker, and the first start takes about 10 minutes.",placements:$8},{id:"more",label:"More options",detail:"Choose for each part, use your own cloud services, or connect to an Oatmilk you run.",placements:null}],Qu=[{id:"custom",label:"Choose for each part",detail:"Keep what you want on this computer, and use the cloud for the rest.",placements:null},{id:"local-ai",label:"Your own cloud, with AI here",detail:"Your own sign-in (Clerk), database and file storage, with every model running on this computer.",placements:mw},{id:"remote",label:"Connect to an Oatmilk you run",detail:"A server you or your team run, or bun run dev on this computer.",placements:null}],SM=[{id:"chat",label:"Ask AI & agents",part:"agents"},{id:"vision",label:"Reading documents",part:"documents"},{id:"classifier",label:"Classifiers",part:"classifiers"},{id:"embedding",label:"Embeddings",part:"agents"}],B2=["name","company"],BBQ={name:"What's your name?",company:"What's your company called?"};A2={value:"",cursor:0}});var J3A={};pQ(J3A,{offlineEnabled:()=>CBQ,localTarget:()=>E3A,isPrivateAddress:()=>D3A,ensureLocalReady:()=>dU,autoSignIn:()=>I2,assertOffline:()=>$BQ});import{isIP as I3A}from"node:net";async function E3A(A){let Q=await $I();if(!Q||Q.mode!=="local"||!Q.runtime||Q.host!==A)return null;return{profile:Q,platform:new i4(Q.runtime)}}async function dU(A,Q){let B=await E3A(A);if(!B)return null;if(await B.platform.trustCertificate().catch(()=>!1),await n4(A))return B;if(!Q.start)throw new n(`Your local Oatmilk at ${A} isn't running.`,y.failure,"Start it with: oatmilk local start");if(Q.onStatus?.("Starting your local Oatmilk…"),await B.platform.start((I)=>Q.onStatus?.(I)),!await SK(A,{timeoutMs:Q.timeoutMs??600000,signal:Q.signal,onWait:(I)=>{if(I>3000)B.platform.trustCertificate().catch(()=>!1);Q.onStatus?.(`Starting your local Oatmilk… ${Math.round(I/1000)} s`)}}))throw new n(`Your local Oatmilk didn't start at ${A}.`,y.failure,"See why with: oatmilk local logs");return B}async function I2(A,Q){let B=(await sQ()).hosts[A];if(B?.credential||!B?.localAccount)return!1;let E=await s8({host:A,email:B.localAccount.email,password:B.localAccount.password,signal:Q});return await zB(A,(I)=>({...I,credential:E})),!0}function D3A(A){let{hostname:Q}=new URL(A),B=Q.replace(/^\[|\]$/g,"").toLowerCase();if(W_(B)||B.endsWith(".local")||B.endsWith(".lan")||B.endsWith(".internal")||B.endsWith(".home.arpa"))return!0;if(I3A(B)===6)return B==="::1"||B.startsWith("fc")||B.startsWith("fd")||B.startsWith("fe80");if(I3A(B)!==4)return!1;let[E,I]=B.split(".").map(Number);return E===127||E===10||E===192&&I===168||E===172&&I>=16&&I<=31||E===169&&I===254}function CBQ(A,Q=process.env){return A||Q.OATMILK_OFFLINE==="1"||Q.OATMILK_OFFLINE==="true"}function $BQ(A){if(!D3A(A))throw new n(`--offline keeps Oatmilk on this computer and its network, and ${A} is on the internet.`,y.usage,"Use your local Oatmilk (oatmilk --local), or leave out --offline.")}var wM=W(()=>{Q5();wQ();j_();S0();Z4();K8()});function G3A(A){let Q=A.inputSchema.properties??{},B=(A.inputSchema.required??[]).filter((I)=>I!=="idempotencyKey");if(!B.length)return"{}";let E=(I)=>I.enum?.[0]??(I.default!==void 0?I.default:I.type==="integer"||I.type==="number"?0:I.type==="boolean"?!1:I.type==="array"?[]:I.type==="object"?{}:"");return JSON.stringify(Object.fromEntries(B.map((I)=>[I,E(Q[I]??{})])),null,2)}function UBQ(A,Q){return(JSON.stringify(A,null,2)??"null").split(`
515
515
  `).flatMap((E)=>{let I=[];for(let J of E.matchAll(/("(?:[^"\\]|\\.)*")(\s*:)?|(-?\d+(?:\.\d+)?(?:e[+-]?\d+)?)|(true|false|null)|([^"\d\-tfn]+|.)/gi))if(J[1]&&J[2])I.push({text:J[1],color:L.info},{text:J[2],color:L.faint});else if(J[1])I.push({text:J[1],color:L.success});else if(J[3])I.push({text:J[3],color:L.warning});else if(J[4])I.push({text:J[4],color:L.accent});else I.push({text:J[0],color:L.muted});let D=/^ */.exec(E)?.[0]??"";if(D&&I[0]?.text.startsWith(D))I[0]={...I[0],text:I[0].text.slice(D.length)};return eQ(I.filter((J)=>J.text),Q,D?[{text:D}]:[],[{text:`${D} `}])})}function C3A({width:A,height:Q}){let B=FB(),[E,I]=OI.useState(null),[D,J]=OI.useState(null),[G,U]=OI.useState({value:"",cursor:0}),[Y,H]=OI.useState(0),[X,N]=OI.useState("browse"),[z,F]=OI.useState({value:"{}",cursor:2}),[V,O]=OI.useState(null),[j,b]=OI.useState(!1),[x,v]=OI.useState(0);OI.useEffect(()=>{M$(B.session.host).then(I,(uA)=>J(CQ(uA)))},[B.session.host]);let w=B.role,k=OI.useMemo(()=>{return jM((E??[]).filter((uA)=>!uA.roles.length||uA.roles.includes(w)),G.value)},[E,G.value,w]),[h,t]=OI.useState(null),[i,UA]=OI.useState(G.value);if(i!==G.value)UA(G.value),H(0);if(E&&h!==E){t(E);let uA=B.route.params.get("action"),sA=uA?k.findIndex((qQ)=>qQ.name===uA):-1;if(sA>=0)H(sA),F({value:G3A(k[sA]),cursor:1}),N("edit")}let CA=k[Math.min(Y,k.length-1)],[GA,iA]=OI.useState(CA?.name);if(GA!==CA?.name)iA(CA?.name),O(null),v(0);let{setHints:jA}=B;OI.useEffect(()=>{jA(X==="edit"?"⏎ run · ⌥⏎ new line · Esc back to the list":"Type to filter · ↑↓ choose · ⏎ fill in and run · Esc sidebar")},[X,jA]);let IQ=async()=>{if(!CA)return;let uA;try{let sA=JSON.parse(z.value||"{}");if(!sA||typeof sA!=="object"||Array.isArray(sA))throw Error("The input must be a JSON object.");uA=sA}catch(sA){O({ok:!1,value:{error:CQ(sA)}});return}if(rH(CA.kind)&&!await B.dialogs.confirm({title:`Run ${CA.name}?`,body:`This ${vM[CA.kind][0]}.`,danger:CA.kind==="destructive",confirmLabel:"Run"}))return;b(!0);try{let sA=!CA.readOnly&&RM(CA)&&typeof uA.idempotencyKey!=="string"?bI():void 0,qQ=await B.api.call(CA.name,uA,{readOnly:CA.readOnly,idempotencyKey:sA});if(!CA.readOnly)B.store.invalidate();O({ok:!0,value:qQ})}catch(sA){O({ok:!1,value:sA instanceof mQ?{error:{code:sA.code,message:sA.message,...sA.details}}:{error:CQ(sA)}})}finally{b(!1),v(0)}};iQ((uA,sA)=>{if(j)return;if(X==="edit"){if(sA.escape){N("browse");return}if(sA.pageDown){v((tA)=>tA+5);return}if(sA.pageUp){v((tA)=>Math.max(0,tA-5));return}let YB=BI(z,uA,sA,1e5);if(YB.type==="submit")IQ();else if(YB.type==="edit")F(YB.state);return}if(sA.escape){if(G.value)U({value:"",cursor:0});else B.setFocus(B.layout.sidebarWidth?"sidebar":"composer");return}if(sA.downArrow){H((YB)=>Math.min(k.length-1,YB+1));return}if(sA.upArrow){H((YB)=>Math.max(0,YB-1));return}if(sA.return&&CA){F({value:G3A(CA),cursor:1}),N("edit");return}let qQ=BI(G,uA,sA,120);if(qQ.type==="edit")U(qQ.state)},{isActive:B.focus==="main"}),z8((uA)=>{if(X==="edit")F((sA)=>j4(sA,uA,1e5));else U((sA)=>j4(sA,uA.replace(/\n/g," "),120))},{isActive:B.focus==="main"});let _A=Math.min(46,Math.floor(A*0.4)),RB=A-_A-2,YA=Math.max(3,Q-3),yA=Math.max(0,Math.min(Y-Math.floor(YA/2),k.length-YA)),YQ=CA?[[{text:CA.name,bold:!0},{text:` ${vM[CA.kind][0]}`,color:vM[CA.kind][1]}],...eQ([{text:CA.summary,color:L.muted}],RB-2).slice(0,4),[{text:`scopes: ${CA.scopes.join(", ")||"none"}`,color:L.faint}]]:[],yQ=Math.max(3,Math.min(10,Math.floor((Q-YQ.length-6)/2))),zQ=V?UBQ(V.value,RB-2):[];return d(e,{flexDirection:"row",width:A,height:Q,children:[d(e,{flexDirection:"column",width:_A,paddingLeft:1,children:[R(e,{borderStyle:"single",borderColor:X==="browse"&&B.focus==="main"?L.focus:L.border,paddingX:1,height:3,children:R(p0,{state:G,width:_A-6,placeholder:"Filter 600+ actions…",focused:X==="browse"&&B.focus==="main"})}),!E?D?R(f,{color:L.danger,wrap:"wrap",children:D}):R(zE,{rows:Math.min(YA,10),width:_A-4,label:"Loading actions"}):k.slice(yA,yA+YA-1).map((uA,sA)=>{let qQ=yA+sA===Y,YB=WD([{text:qQ?`${hA.pointer} `:" ",color:L.focus},{text:uA.name,color:qQ?L.focus:uA.readOnly?L.text:vM[uA.kind][1]}],_A-2);return R(f,{wrap:"truncate-end",children:R8(YB,_A-2).map((tA,WQ)=>R(f,{color:tA.color,backgroundColor:qQ?L.selectionBg:void 0,children:tA.text},WQ))},uA.name)})]}),d(e,{flexDirection:"column",width:RB,paddingLeft:1,borderStyle:"single",borderTop:!1,borderBottom:!1,borderRight:!1,borderColor:L.border,children:[R(L4,{lines:YQ,height:YQ.length}),d(f,{color:L.faint,children:["Input (JSON)",X==="browse"?" · ⏎ to edit":""]}),R(e,{borderStyle:"single",borderColor:X==="edit"?L.focus:L.border,paddingX:1,minHeight:3,children:R(p0,{state:z,width:RB-6,focused:X==="edit"&&B.focus==="main",maxRows:yQ})}),j?R(f0,{label:`Running ${CA?.name}…`}):V?d(PB,{children:[d(f,{color:V.ok?L.success:L.danger,children:[V.ok?`${hA.done} Done`:`${hA.failed} Didn't run`,R(f,{color:L.faint,children:" PgUp PgDn scroll"})]}),R(L4,{lines:zQ,offset:Math.min(x,Math.max(0,zQ.length-3)),height:Math.max(2,Q-YQ.length-yQ-6)})]}):null]})]})}var OI,vM;var $3A=W(async()=>{gM();SE();wQ();RD();BE();bB();HQ();await $0([dB(),gD(),FG(),vD(),g8()]);OI=pA(JQ(),1);vM={read:["reads",L.success],write:["changes data",L.info],access:["grants access",L.warning],destructive:["deletes or voids",L.danger],external:["emails or reaches outside",L.warning]}});function U3A(A){let Q=BigInt(A.incomeMinor)-BigInt(A.incomeRefundMinor)-BigInt(A.expenseMinor)+BigInt(A.expenseRefundMinor),B=Q>0n?"profit":Q<0n?"loss":"even";return{currency:A.currency,moneyInMinor:A.incomeMinor,moneyOutMinor:A.expenseMinor,result:{kind:B,label:YBQ[B],amountMinor:(Q<0n?-Q:Q).toString()},refundsIncluded:BigInt(A.incomeRefundMinor)>0n||BigInt(A.expenseRefundMinor)>0n}}var YBQ;var Y3A=W(()=>{iH();YBQ={profit:"Profit",loss:"Loss",even:"Break even"}});function bM(A,Q){let B=(E)=>{if(Array.isArray(E))return E.map(B);if(E&&typeof E==="object")return Object.fromEntries(Object.keys(E).sort().filter((I)=>E[I]!==void 0).map((I)=>[I,B(E[I])]));return E};return`${A} ${JSON.stringify(B(Q))}`}class Bu{caller;now;entries=new Map;listeners=new Map;mounted=new Map;inflight=new Map;everything=new Set;version=0;constructor(A,Q=Date.now){this.caller=A;this.now=Q}get(A){return this.entries.get(A)}subscribe(A,Q){let B=this.listeners.get(A)??new Set;return B.add(Q),this.listeners.set(A,B),()=>{B.delete(Q)}}set(A,Q){this.entries.set(A,Q),this.version+=1;for(let B of this.listeners.get(A)??[])B();for(let B of this.everything)B()}subscribeAll(A){return this.everything.add(A),()=>{this.everything.delete(A)}}get changes(){return this.version}load(A,Q,B={}){let E=bM(A,Q),I=this.entries.get(E);if(I&&I.updatedAt>0&&!I.stale&&this.now()-I.updatedAt<KBQ&&!B.force)return Promise.resolve(I.data);let J=this.inflight.get(E);if(J)return J;let G=I??{action:A,input:Q,loading:!1,updatedAt:0,stale:!1};this.set(E,{...G,loading:!0,error:void 0});let U=this.caller.call(A,Q,{readOnly:!0}).then((Y)=>{return this.set(E,{action:A,input:Q,data:Y,loading:!1,updatedAt:this.now(),stale:!1}),Y},(Y)=>{let H=this.entries.get(E)??G;throw this.set(E,{...H,error:Y,loading:!1}),Y}).finally(()=>this.inflight.delete(E));return this.inflight.set(E,U),U}prefetch(A,Q){this.load(A,Q).catch(()=>{return})}mount(A){return this.mounted.set(A,(this.mounted.get(A)??0)+1),()=>{let Q=(this.mounted.get(A)??1)-1;if(Q<=0)this.mounted.delete(A);else this.mounted.set(A,Q)}}activeReads(){return[...this.mounted.keys()].flatMap((A)=>{let Q=this.entries.get(A);return Q&&!Q.error?[{action:Q.action,input:Q.input}]:[]})}invalidate(A=()=>!0){for(let[Q,B]of this.entries){if(!A(B.action,B.input))continue;if(this.set(Q,{...B,stale:!0}),this.mounted.has(Q))this.load(B.action,B.input,{force:!0}).catch(()=>{return})}}clear(){this.entries.clear(),this.inflight.clear();for(let A of this.listeners.values())for(let Q of A)Q()}}function K3A(A,Q){let B=JSON.stringify(Q),E=G1.useCallback((I)=>A.subscribeAll(I),[A]);return G1.useSyncExternalStore(E,()=>A.changes),G1.useEffect(()=>{let I=JSON.parse(B),D=I.map((J)=>A.mount(bM(J.action,J.input)));for(let J of I)A.load(J.action,J.input).catch(()=>{return});return()=>{for(let J of D)J()}},[A,B]),Q.map((I)=>A.get(bM(I.action,I.input))??{action:I.action,input:I.input,loading:!0,updatedAt:0,stale:!1})}function VG(A,Q,B){let E=B?bM(Q,B):"",I=G1.useCallback((U)=>E?A.subscribe(E,U):()=>{return},[A,E]),D=G1.useSyncExternalStore(I,()=>E?A.get(E):void 0),J=B?JSON.stringify(B):null;G1.useEffect(()=>{if(!E||!J)return;let U=A.mount(E);return A.load(Q,JSON.parse(J)).catch(()=>{return}),U},[A,E,Q,J]);let G=G1.useCallback(()=>{if(J)A.load(Q,JSON.parse(J),{force:!0}).catch(()=>{return})},[A,Q,J]);return G1.useMemo(()=>({data:D?.data,error:D?.data===void 0?D?.error:void 0,loading:!!E&&D?.data===void 0&&!D?.error,refreshing:!!D?.loading&&D.data!==void 0,refresh:G}),[D,E,G])}var G1,KBQ=30000;var E2=W(()=>{G1=pA(JQ(),1)});var H3A=()=>{};var X3A=W(()=>{H3A()});var Iu={};pQ(Iu,{version:()=>P3A,useFormStatus:()=>T3A,useFormState:()=>g3A,unstable_batchedUpdates:()=>R3A,requestFormReset:()=>j3A,preloadModule:()=>W3A,preload:()=>L3A,preinitModule:()=>O3A,preinit:()=>_3A,prefetchDNS:()=>V3A,preconnect:()=>M3A,flushSync:()=>F3A,createPortal:()=>q3A,__DOM_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE:()=>z3A});function N3A(A){var Q="https://react.dev/errors/"+A;if(1<arguments.length){Q+="?args[]="+encodeURIComponent(arguments[1]);for(var B=2;B<arguments.length;B++)Q+="&args[]="+encodeURIComponent(arguments[B])}return"Minified React error #"+A+"; visit "+Q+" for the full message or use the non-minified dev environment for full errors and additional helpful warnings."}function _G(){}function XBQ(A,Q,B){var E=3<arguments.length&&arguments[3]!==void 0?arguments[3]:null;return{$$typeof:HBQ,key:E==null?null:""+E,children:A,containerInfo:Q,implementation:B}}function kM(A,Q){if(A==="font")return"";if(typeof Q==="string")return Q==="use-credentials"?Q:""}var Z3A,FE,HBQ,D2,z3A,q3A=function(A,Q){var B=2<arguments.length&&arguments[2]!==void 0?arguments[2]:null;if(!Q||Q.nodeType!==1&&Q.nodeType!==9&&Q.nodeType!==11)throw Error(N3A(299));return XBQ(A,Q,null,B)},F3A=function(A){var Q=D2.T,B=FE.p;try{if(D2.T=null,FE.p=2,A)return A()}finally{D2.T=Q,FE.p=B,FE.d.f()}},M3A=function(A,Q){typeof A==="string"&&(Q?(Q=Q.crossOrigin,Q=typeof Q==="string"?Q==="use-credentials"?Q:"":void 0):Q=null,FE.d.C(A,Q))},V3A=function(A){typeof A==="string"&&FE.d.D(A)},_3A=function(A,Q){if(typeof A==="string"&&Q&&typeof Q.as==="string"){var B=Q.as,E=kM(B,Q.crossOrigin),I=typeof Q.integrity==="string"?Q.integrity:void 0,D=typeof Q.fetchPriority==="string"?Q.fetchPriority:void 0;B==="style"?FE.d.S(A,typeof Q.precedence==="string"?Q.precedence:void 0,{crossOrigin:E,integrity:I,fetchPriority:D}):B==="script"&&FE.d.X(A,{crossOrigin:E,integrity:I,fetchPriority:D,nonce:typeof Q.nonce==="string"?Q.nonce:void 0})}},O3A=function(A,Q){if(typeof A==="string")if(typeof Q==="object"&&Q!==null){if(Q.as==null||Q.as==="script"){var B=kM(Q.as,Q.crossOrigin);FE.d.M(A,{crossOrigin:B,integrity:typeof Q.integrity==="string"?Q.integrity:void 0,nonce:typeof Q.nonce==="string"?Q.nonce:void 0})}}else Q==null&&FE.d.M(A)},L3A=function(A,Q){if(typeof A==="string"&&typeof Q==="object"&&Q!==null&&typeof Q.as==="string"){var B=Q.as,E=kM(B,Q.crossOrigin);FE.d.L(A,B,{crossOrigin:E,integrity:typeof Q.integrity==="string"?Q.integrity:void 0,nonce:typeof Q.nonce==="string"?Q.nonce:void 0,type:typeof Q.type==="string"?Q.type:void 0,fetchPriority:typeof Q.fetchPriority==="string"?Q.fetchPriority:void 0,referrerPolicy:typeof Q.referrerPolicy==="string"?Q.referrerPolicy:void 0,imageSrcSet:typeof Q.imageSrcSet==="string"?Q.imageSrcSet:void 0,imageSizes:typeof Q.imageSizes==="string"?Q.imageSizes:void 0,media:typeof Q.media==="string"?Q.media:void 0})}},W3A=function(A,Q){if(typeof A==="string")if(Q){var B=kM(Q.as,Q.crossOrigin);FE.d.m(A,{as:typeof Q.as==="string"&&Q.as!=="script"?Q.as:void 0,crossOrigin:B,integrity:typeof Q.integrity==="string"?Q.integrity:void 0})}else FE.d.m(A)},j3A=function(A){FE.d.r(A)},R3A=function(A,Q){return A(Q)},g3A=function(A,Q,B){return D2.H.useFormState(A,Q,B)},T3A=function(){return D2.H.useHostTransitionStatus()},P3A="19.2.8";var S3A=W(()=>{Z3A=pA(JQ(),1);FE={d:{f:_G,r:function(){throw Error(N3A(522))},D:_G,C:_G,L:_G,m:_G,X:_G,S:_G,M:_G},p:0,findDOMNode:null},HBQ=Symbol.for("react.portal");D2=Z3A.__CLIENT_INTERNALS_DO_NOT_USE_OR_WARN_USERS_THEY_CANNOT_UPGRADE;z3A=FE});var b3A=RA((KhQ,v3A)=>{S3A();function w3A(){if(typeof __REACT_DEVTOOLS_GLOBAL_HOOK__>"u"||typeof __REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE!=="function")return;try{__REACT_DEVTOOLS_GLOBAL_HOOK__.checkDCE(w3A)}catch(A){console.error(A)}}w3A(),v3A.exports=Iu});function ZBQ(A){if(!A||typeof document>"u")return;let Q=document.head||document.getElementsByTagName("head")[0],B=document.createElement("style");B.type="text/css",Q.appendChild(B),B.styleSheet?B.styleSheet.cssText=A:B.appendChild(document.createTextNode(A))}class x3A{constructor(){this.subscribe=(A)=>{return this.subscribers.push(A),this.getActiveToasts().forEach((Q)=>A(Q)),()=>{let Q=this.subscribers.indexOf(A);this.subscribers.splice(Q,1)}},this.publish=(A)=>{this.subscribers.forEach((Q)=>Q(A))},this.addToast=(A)=>{this.publish(A),this.toasts=[...this.toasts,A],this.trimHistory()},this.trimHistory=()=>{let A=this.toasts.length-qBQ;if(A<=0)return;this.toasts=this.toasts.filter((Q)=>{if(A>0&&this.dismissedToasts.has(Q.id))return this.dismissedToasts.delete(Q.id),A--,!1;return!0})},this.create=(A)=>{let{message:Q,...B}=A,E=k3A(A),I=this.pendingDismissals.get(E);if(I!==void 0)cancelAnimationFrame(I),this.pendingDismissals.delete(E),this.dismissedToasts.delete(E);let D=this.dismissedToasts.has(E),J=A.dismissible===void 0?!0:A.dismissible;if(D)this.dismissedToasts.delete(E),this.toasts=this.toasts.filter((U)=>U.id!==E);if(D?void 0:this.toasts.find((U)=>{return U.id===E}))this.toasts=this.toasts.map((U)=>{if(U.id===E)return this.publish({...U,...A,id:E,title:Q}),{...U,...A,id:E,dismissible:J,title:Q};return U});else this.addToast({title:Q,...B,dismissible:J,id:E});return E},this.dismiss=(A)=>{if(A===void 0||A===null)return this.getActiveToasts().forEach((B)=>{this.dismissedToasts.add(B.id),this.subscribers.forEach((E)=>E({id:B.id,dismiss:!0}))}),A;this.dismissedToasts.add(A);let Q=this.pendingDismissals.get(A);if(Q!==void 0)cancelAnimationFrame(Q);return this.pendingDismissals.set(A,requestAnimationFrame(()=>{this.pendingDismissals.delete(A),this.subscribers.forEach((B)=>B({id:A,dismiss:!0}))})),A},this.message=(A,Q)=>{return this.create({...Q,message:A,type:void 0})},this.error=(A,Q)=>{return this.create({...Q,message:A,type:"error"})},this.success=(A,Q)=>{return this.create({...Q,type:"success",message:A})},this.info=(A,Q)=>{return this.create({...Q,type:"info",message:A})},this.warning=(A,Q)=>{return this.create({...Q,type:"warning",message:A})},this.loading=(A,Q)=>{return this.create({...Q,type:"loading",message:A})},this.promise=(A,Q)=>{if(!Q)return;let B=void 0;if(Q.loading!==void 0)B=this.create({...Q,promise:A,type:"loading",message:Q.loading,description:typeof Q.description!=="function"?Q.description:void 0});let E=Promise.resolve(A instanceof Function?A():A),I=B!==void 0,D,J=E.then(async(U)=>{if(D=["resolve",U],T8.default.isValidElement(U))I=!1,this.create({id:B,type:"default",message:U});else if(MBQ(U)&&!U.ok){I=!1;let H=typeof Q.error==="function"?await Q.error(`HTTP error! status: ${U.status}`):Q.error,X=typeof Q.description==="function"?await Q.description(`HTTP error! status: ${U.status}`):Q.description,z=typeof H==="object"&&!T8.default.isValidElement(H)?H:{message:H};this.create({id:B,type:"error",description:X,...z})}else if(U instanceof Error){I=!1;let H=typeof Q.error==="function"?await Q.error(U):Q.error,X=typeof Q.description==="function"?await Q.description(U):Q.description,z=typeof H==="object"&&!T8.default.isValidElement(H)?H:{message:H};this.create({id:B,type:"error",description:X,...z})}else if(Q.success!==void 0){I=!1;let H=typeof Q.success==="function"?await Q.success(U):Q.success,X=typeof Q.description==="function"?await Q.description(U):Q.description,z=typeof H==="object"&&!T8.default.isValidElement(H)?H:{message:H};this.create({id:B,type:"success",description:X,...z})}}).catch(async(U)=>{if(D=["reject",U],Q.error!==void 0){I=!1;let Y=typeof Q.error==="function"?await Q.error(U):Q.error,H=typeof Q.description==="function"?await Q.description(U):Q.description,N=typeof Y==="object"&&!T8.default.isValidElement(Y)?Y:{message:Y};this.create({id:B,type:"error",description:H,...N})}}).finally(()=>{if(I)this.dismiss(B),B=void 0;Q.finally==null||Q.finally.call(Q)}),G=()=>new Promise((U,Y)=>J.then(()=>D[0]==="reject"?Y(D[1]):U(D[1])).catch(Y));if(typeof B!=="string"&&typeof B!=="number")return{unwrap:G};else return Object.assign(B,{unwrap:G})},this.custom=(A,Q)=>{let B=k3A(Q);return this.create({...Q,jsx:A(B),id:B,type:void 0}),B},this.getActiveToasts=()=>{return this.toasts.filter((A)=>!this.dismissedToasts.has(A.id))},this.subscribers=[],this.toasts=[],this.dismissedToasts=new Set,this.pendingDismissals=new Map}}var T8,NBQ,HhQ,zBQ=1,qBQ=100,k3A=(A)=>{var Q;return typeof(A==null?void 0:A.id)==="number"||(A==null?void 0:(Q=A.id)==null?void 0:Q.length)>0?A.id:zBQ++},C1,FBQ=(A,Q)=>{return C1.message(A,Q)},MBQ=(A)=>{return A&&typeof A==="object"&&"ok"in A&&typeof A.ok==="boolean"&&"status"in A&&typeof A.status==="number"},VBQ,_BQ=()=>C1.toasts,OBQ=()=>C1.getActiveToasts(),LBQ;var y3A=W(()=>{T8=pA(JQ(),1),NBQ=pA(b3A(),1);HhQ=Array(12).fill(0);C1=new x3A,VBQ=FBQ,LBQ=Object.assign(VBQ,{success:C1.success,info:C1.info,warning:C1.warning,error:C1.error,custom:C1.custom,message:C1.message,promise:C1.promise,dismiss:C1.dismiss,loading:C1.loading},{getHistory:_BQ,getToasts:OBQ});ZBQ("[data-sonner-toaster][dir=ltr],html[dir=ltr]{--toast-icon-margin-start:-3px;--toast-icon-margin-end:4px;--toast-svg-margin-start:-1px;--toast-svg-margin-end:0px;--toast-button-margin-start:auto;--toast-button-margin-end:0;--toast-close-button-start:0;--toast-close-button-end:unset;--toast-close-button-transform:translate(-35%, -35%)}[data-sonner-toaster][dir=rtl],html[dir=rtl]{--toast-icon-margin-start:4px;--toast-icon-margin-end:-3px;--toast-svg-margin-start:0px;--toast-svg-margin-end:-1px;--toast-button-margin-start:0;--toast-button-margin-end:auto;--toast-close-button-start:unset;--toast-close-button-end:0;--toast-close-button-transform:translate(35%, -35%)}[data-sonner-toaster]{position:fixed;width:var(--width);font-family:ui-sans-serif,system-ui,-apple-system,BlinkMacSystemFont,Segoe UI,Roboto,Helvetica Neue,Arial,Noto Sans,sans-serif,Apple Color Emoji,Segoe UI Emoji,Segoe UI Symbol,Noto Color Emoji;--gray1:hsl(0, 0%, 99%);--gray2:hsl(0, 0%, 97.3%);--gray3:hsl(0, 0%, 95.1%);--gray4:hsl(0, 0%, 93%);--gray5:hsl(0, 0%, 90.9%);--gray6:hsl(0, 0%, 88.7%);--gray7:hsl(0, 0%, 85.8%);--gray8:hsl(0, 0%, 78%);--gray9:hsl(0, 0%, 56.1%);--gray10:hsl(0, 0%, 52.3%);--gray11:hsl(0, 0%, 43.5%);--gray12:hsl(0, 0%, 9%);--border-radius:8px;box-sizing:border-box;padding:0;margin:0;list-style:none;outline:0;z-index:999999999;transition:transform .4s ease}@media (hover:none) and (pointer:coarse){[data-sonner-toaster][data-lifted=true]{transform:none}}[data-sonner-toaster][data-x-position=right]{right:var(--offset-right)}[data-sonner-toaster][data-x-position=left]{left:var(--offset-left)}[data-sonner-toaster][data-x-position=center]{left:50%;transform:translateX(-50%)}[data-sonner-toaster][data-y-position=top]{top:var(--offset-top)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--offset-bottom)}[data-sonner-toast]{--y:translateY(100%);--lift-amount:calc(var(--lift) * var(--gap));z-index:var(--z-index);position:absolute;opacity:0;transform:var(--y);touch-action:none;transition:transform .4s,opacity .4s,height .4s,box-shadow .2s;box-sizing:border-box;outline:0;overflow-wrap:anywhere}[data-sonner-toast][data-styled=true]{padding:16px;background:var(--normal-bg);border:1px solid var(--normal-border);color:var(--normal-text);border-radius:var(--border-radius);box-shadow:0 4px 12px rgba(0,0,0,.1);width:var(--width);font-size:13px;display:flex;align-items:center;gap:6px}[data-sonner-toast]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-y-position=top]{top:0;--y:translateY(-100%);--lift:1;--lift-amount:calc(1 * var(--gap))}[data-sonner-toast][data-y-position=bottom]{bottom:0;--y:translateY(100%);--lift:-1;--lift-amount:calc(var(--lift) * var(--gap))}[data-sonner-toast][data-styled=true] [data-description]{font-weight:400;line-height:1.4;color:#3f3f3f}[data-rich-colors=true][data-sonner-toast][data-styled=true] [data-description]{color:inherit}[data-sonner-toaster][data-sonner-theme=dark] [data-description]{color:#e8e8e8}[data-sonner-toast][data-styled=true] [data-title]{font-weight:500;line-height:1.5;color:inherit}[data-sonner-toast][data-styled=true] [data-icon]{display:flex;height:16px;width:16px;position:relative;justify-content:flex-start;align-items:center;flex-shrink:0;margin-left:var(--toast-icon-margin-start);margin-right:var(--toast-icon-margin-end)}[data-sonner-toast][data-promise=true] [data-icon]>svg{opacity:0;transform:scale(.8);transform-origin:center;animation:sonner-fade-in .3s ease forwards}[data-sonner-toast][data-styled=true] [data-icon]>*{flex-shrink:0}[data-sonner-toast][data-styled=true] [data-icon] svg{margin-left:var(--toast-svg-margin-start);margin-right:var(--toast-svg-margin-end)}[data-sonner-toast][data-styled=true] [data-content]{display:flex;flex-direction:column;gap:2px;flex:1;min-width:0}[data-sonner-toast][data-styled=true] [data-button]{border-radius:4px;padding-left:8px;padding-right:8px;height:24px;font-size:12px;color:var(--normal-bg);background:var(--normal-text);margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end);border:none;font-weight:500;cursor:pointer;outline:0;display:flex;align-items:center;flex-shrink:0;transition:opacity .4s,box-shadow .2s}[data-sonner-toast][data-styled=true] [data-button]:focus-visible{box-shadow:0 0 0 2px rgba(0,0,0,.4)}[data-sonner-toast][data-styled=true] [data-button]:first-of-type{margin-left:var(--toast-button-margin-start);margin-right:var(--toast-button-margin-end)}[data-sonner-toast][data-styled=true] [data-cancel]{color:var(--normal-text);background:rgba(0,0,0,.08)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-styled=true] [data-cancel]{background:rgba(255,255,255,.3)}[data-sonner-toast][data-styled=true] [data-close-button]{position:absolute;left:var(--toast-close-button-start);right:var(--toast-close-button-end);top:0;height:20px;width:20px;display:flex;justify-content:center;align-items:center;padding:0;color:var(--normal-text);background:var(--normal-bg);border:1px solid var(--normal-border);transform:var(--toast-close-button-transform);border-radius:50%;cursor:pointer;z-index:1;transition:opacity .1s,background .2s,border-color .2s}[data-sonner-toast][data-styled=true] [data-close-button]:focus-visible{box-shadow:0 4px 12px rgba(0,0,0,.1),0 0 0 2px rgba(0,0,0,.2)}[data-sonner-toast][data-styled=true] [data-disabled=true]{cursor:not-allowed}[data-sonner-toast][data-styled=true]:hover [data-close-button]:hover{background:var(--gray2);border-color:var(--gray5)}[data-sonner-toast][data-swiping=true]::before{content:'';position:absolute;left:-100%;right:-100%;height:100%;z-index:-1}[data-sonner-toast][data-y-position=top][data-swiping=true]::before{bottom:50%;transform:scaleY(3) translateY(50%)}[data-sonner-toast][data-y-position=bottom][data-swiping=true]::before{top:50%;transform:scaleY(3) translateY(-50%)}[data-sonner-toast][data-swiping=false][data-removed=true]::before{content:'';position:absolute;inset:0;transform:scaleY(2)}[data-sonner-toast][data-expanded=true]::after{content:'';position:absolute;left:0;height:calc(var(--gap) + 1px);bottom:100%;width:100%}[data-sonner-toast][data-mounted=true]{--y:translateY(0);opacity:1}[data-sonner-toast][data-expanded=false][data-front=false]{--scale:var(--toasts-before) * 0.05 + 1;--y:translateY(calc(var(--lift-amount) * var(--toasts-before))) scale(calc(-1 * var(--scale)));height:var(--front-toast-height)}[data-sonner-toast]>*{transition:opacity .4s}[data-sonner-toast][data-x-position=right]{right:0}[data-sonner-toast][data-x-position=left]{left:0}[data-sonner-toast][data-expanded=false][data-front=false][data-styled=true]>*{opacity:0}[data-sonner-toast][data-visible=false]{opacity:0;pointer-events:none}[data-sonner-toast][data-mounted=true][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset)));height:var(--initial-height)}[data-sonner-toast][data-removed=true][data-front=true][data-swipe-out=false]{--y:translateY(calc(var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=true]{--y:translateY(calc(var(--lift) * var(--offset) + var(--lift) * -100%));opacity:0}[data-sonner-toast][data-removed=true][data-front=false][data-swipe-out=false][data-expanded=false]{--y:translateY(40%);opacity:0;transition:transform .5s,opacity .2s}[data-sonner-toast][data-removed=true][data-front=false]::before{height:calc(var(--initial-height) + 20%)}[data-sonner-toast][data-swiping=true]{transform:var(--y) translateY(var(--swipe-amount-y,0)) translateX(var(--swipe-amount-x,0));transition:none}[data-sonner-toast][data-swiped=true]{-webkit-user-select:none;user-select:none}[data-sonner-toast][data-swipe-out=true][data-y-position=bottom],[data-sonner-toast][data-swipe-out=true][data-y-position=top]{animation-duration:.2s;animation-timing-function:ease-out;animation-fill-mode:forwards}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=left]{animation-name:swipe-out-left}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=right]{animation-name:swipe-out-right}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=up]{animation-name:swipe-out-up}[data-sonner-toast][data-swipe-out=true][data-swipe-direction=down]{animation-name:swipe-out-down}@keyframes swipe-out-left{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) - 100%));opacity:0}}@keyframes swipe-out-right{from{transform:var(--y) translateX(var(--swipe-amount-x));opacity:1}to{transform:var(--y) translateX(calc(var(--swipe-amount-x) + 100%));opacity:0}}@keyframes swipe-out-up{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) - 100%));opacity:0}}@keyframes swipe-out-down{from{transform:var(--y) translateY(var(--swipe-amount-y));opacity:1}to{transform:var(--y) translateY(calc(var(--swipe-amount-y) + 100%));opacity:0}}@media (max-width:600px){[data-sonner-toaster]{position:fixed;right:var(--mobile-offset-right);left:var(--mobile-offset-left);width:100%}[data-sonner-toaster][dir=rtl]{left:calc(var(--mobile-offset-left) * -1)}[data-sonner-toaster] [data-sonner-toast]{left:0;right:0;width:calc(100% - var(--mobile-offset-left) * 2)}[data-sonner-toaster][data-x-position=left]{left:var(--mobile-offset-left)}[data-sonner-toaster][data-y-position=bottom]{bottom:var(--mobile-offset-bottom)}[data-sonner-toaster][data-y-position=top]{top:var(--mobile-offset-top)}[data-sonner-toaster][data-x-position=center]{left:var(--mobile-offset-left);right:var(--mobile-offset-right);transform:none}}[data-sonner-toaster][data-sonner-theme=light]{--normal-bg:#fff;--normal-border:var(--gray4);--normal-text:var(--gray12);--success-bg:hsl(143, 85%, 96%);--success-border:hsl(145, 92%, 87%);--success-text:hsl(140, 100%, 27%);--info-bg:hsl(208, 100%, 97%);--info-border:hsl(221, 91%, 93%);--info-text:hsl(210, 92%, 45%);--warning-bg:hsl(49, 100%, 97%);--warning-border:hsl(49, 91%, 84%);--warning-text:hsl(31, 92%, 45%);--error-bg:hsl(359, 100%, 97%);--error-border:hsl(359, 100%, 94%);--error-text:hsl(360, 100%, 45%)}[data-sonner-toaster][data-sonner-theme=light] [data-sonner-toast][data-invert=true]{--normal-bg:#000;--normal-border:hsl(0, 0%, 20%);--normal-text:var(--gray1)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast][data-invert=true]{--normal-bg:#fff;--normal-border:var(--gray3);--normal-text:var(--gray12)}[data-sonner-toaster][data-sonner-theme=dark]{--normal-bg:#000;--normal-bg-hover:hsl(0, 0%, 12%);--normal-border:hsl(0, 0%, 20%);--normal-border-hover:hsl(0, 0%, 25%);--normal-text:var(--gray1);--success-bg:hsl(150, 100%, 6%);--success-border:hsl(147, 100%, 12%);--success-text:hsl(150, 86%, 65%);--info-bg:hsl(215, 100%, 6%);--info-border:hsl(223, 43%, 17%);--info-text:hsl(216, 87%, 65%);--warning-bg:hsl(64, 100%, 6%);--warning-border:hsl(60, 100%, 9%);--warning-text:hsl(46, 87%, 65%);--error-bg:hsl(358, 76%, 10%);--error-border:hsl(357, 89%, 16%);--error-text:hsl(358, 100%, 81%)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]{background:var(--normal-bg);border-color:var(--normal-border);color:var(--normal-text)}[data-sonner-toaster][data-sonner-theme=dark] [data-sonner-toast] [data-close-button]:hover{background:var(--normal-bg-hover);border-color:var(--normal-border-hover)}[data-rich-colors=true][data-sonner-toast][data-type=success]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=success] [data-close-button]{background:var(--success-bg);border-color:var(--success-border);color:var(--success-text)}[data-rich-colors=true][data-sonner-toast][data-type=info]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=info] [data-close-button]{background:var(--info-bg);border-color:var(--info-border);color:var(--info-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=warning] [data-close-button]{background:var(--warning-bg);border-color:var(--warning-border);color:var(--warning-text)}[data-rich-colors=true][data-sonner-toast][data-type=error]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}[data-rich-colors=true][data-sonner-toast][data-type=error] [data-close-button]{background:var(--error-bg);border-color:var(--error-border);color:var(--error-text)}.sonner-loading-wrapper{--size:16px;height:var(--size);width:var(--size);position:absolute;inset:0;z-index:10}.sonner-loading-wrapper[data-visible=false]{transform-origin:center;animation:sonner-fade-out .2s ease forwards}.sonner-spinner{position:relative;top:50%;left:50%;height:var(--size);width:var(--size)}.sonner-loading-bar{animation:sonner-spin 1.2s linear infinite;background:var(--gray11);border-radius:6px;height:8%;left:-10%;position:absolute;top:-3.9%;width:24%}.sonner-loading-bar:first-child{animation-delay:-1.2s;transform:rotate(.0001deg) translate(146%)}.sonner-loading-bar:nth-child(2){animation-delay:-1.1s;transform:rotate(30deg) translate(146%)}.sonner-loading-bar:nth-child(3){animation-delay:-1s;transform:rotate(60deg) translate(146%)}.sonner-loading-bar:nth-child(4){animation-delay:-.9s;transform:rotate(90deg) translate(146%)}.sonner-loading-bar:nth-child(5){animation-delay:-.8s;transform:rotate(120deg) translate(146%)}.sonner-loading-bar:nth-child(6){animation-delay:-.7s;transform:rotate(150deg) translate(146%)}.sonner-loading-bar:nth-child(7){animation-delay:-.6s;transform:rotate(180deg) translate(146%)}.sonner-loading-bar:nth-child(8){animation-delay:-.5s;transform:rotate(210deg) translate(146%)}.sonner-loading-bar:nth-child(9){animation-delay:-.4s;transform:rotate(240deg) translate(146%)}.sonner-loading-bar:nth-child(10){animation-delay:-.3s;transform:rotate(270deg) translate(146%)}.sonner-loading-bar:nth-child(11){animation-delay:-.2s;transform:rotate(300deg) translate(146%)}.sonner-loading-bar:nth-child(12){animation-delay:-.1s;transform:rotate(330deg) translate(146%)}@keyframes sonner-fade-in{0%{opacity:0;transform:scale(.8)}100%{opacity:1;transform:scale(1)}}@keyframes sonner-fade-out{0%{opacity:1;transform:scale(1)}100%{opacity:0;transform:scale(.8)}}@keyframes sonner-spin{0%{opacity:1}100%{opacity:.15}}@media (prefers-reduced-motion){.sonner-loading-bar,[data-sonner-toast],[data-sonner-toast]>*{transition:none!important;animation:none!important}}.sonner-loader{position:absolute;top:50%;left:50%;transform:translate(-50%,-50%);transform-origin:center;transition:opacity .2s,transform .2s}.sonner-loader[data-visible=false]{opacity:0;transform:scale(.8) translate(-50%,-50%)}")});var f3A=W(()=>{y3A();yH()});function RBQ(A){return Boolean(A.voided_at)&&["deleted","import_undo"].includes(A.provider_metadata?.voidedReason??"")}function gBQ(A){if(A.autopilot_state!=="needs_you"||A.type==="suspense")return A.autopilot_state;let Q=A.autopilot_ask==="choose_category"&&(Boolean(A.category_id)||A.type==="transfer"),B=A.autopilot_ask==="confirm_business"&&A.human_corrected&&(Boolean(A.category_id)||A.type==="transfer");return Q||B?"working":A.autopilot_state}function J2(A){if(RBQ(A))return"deleted";if(A.status==="reviewed")return A.provider_metadata?.completedBy==="autopilot"?"auto_reviewed":"reviewed";let Q=gBQ(A);if(Q==="needs_you")return jBQ[A.autopilot_ask??""]??"needs_review";if(Q==="waiting")return"ai_waiting";if(Q==="working")return"ai_working";return A.provider_metadata?.taxKnown===!1?"tax_to_confirm":"needs_review"}function Eu(A){if(["expense","fee","income_refund"].includes(A.type))return"-";if(["income","refund"].includes(A.type))return"+";return""}var WBQ,RhQ,jBQ;var Du=W(()=>{Ph();X3A();f3A();WBQ=["date","category","tags","account","source","type","status","amount"],RhQ=["merchant",...WBQ],jBQ={forward_receipt:"needs_receipt",reimbursement_receipts:"needs_receipt",contractor_invoice:"needs_invoice",choose_contractor:"needs_contractor",choose_category:"needs_category",confirm_business:"needs_business_check",confirm_income:"needs_income_check",confirm_tax:"tax_to_confirm",match_payout:"needs_payout_match",approve:"ready_to_approve",import_statement:"needs_statement"}});var h3A=()=>{};var u3A=()=>{};var TBQ,vhQ,Gu,Ju,PBQ,SBQ,bhQ,khQ,xhQ,yhQ,wBQ,fhQ;var m3A=W(()=>{u3A();TBQ=String.raw`(?:(?:temporary|temp|initial|new|current|old|default|one[- ]?time)\s+)?(?:password|passphrase|passcode|pass\s?code|pwd|mot\s+de\s+passe|mdp|contraseña)`,vhQ=new RegExp(String.raw`\b(${TBQ})\b((?:(?:[ \t]{0,3}(?:\bis\b|\bwas\b|\bwill\s+be\b|:|=|→)|[ \t]+[-–])[ \t]{0,3}){1,3}(?:\r?\n[ \t]*)?)(["'\`“‘]?)((?:[^\s"'\`”’<>]*[^\s"'\`”’<>.,;:!?])?)`,"gi"),Gu=String.raw`(?:verification|security|authentication|login|log-?in|sign-?in|access|recovery|backup|one[- ]?time|2fa|mfa|reset|temporary|temp|magic)`,Ju=String.raw`(?:code|codes|passcode|pass\s?code|pin|otp)`,PBQ=String.raw`(?:${Gu}\s+${Ju}|(?:code|c[oó]digo)\s+de\s+(?:v[eé]rification|verificaci[oó]n|s[eé]curit[eé]|seguridad|connexion|acceso)|${Ju})`,SBQ=String.raw`(?:[A-Za-z]{1,2}-)?\d(?:[ -]?\d){3,9}(?!\d)`,bhQ=new RegExp(String.raw`\b(${PBQ})\b((?:[ \t]{0,3}(?:\bis\b|\bwas\b|\bwill\s+be\b|:|=|-|–)){0,2}[ \t]{0,3}(?:\r?\n[ \t]*)?)(["'“(]?)(${SBQ})`,"gi"),khQ=new RegExp(String.raw`(?<![\d$€£.,#/-])\b((?:[A-Za-z]{1,2}-)?\d(?:[ -]?\d){3,7})(?!\d)(?=[ \t]{0,3}(?:is|as)\s+your\b[^\n]{0,40}\b${Ju}\b)`,"gi"),xhQ=new RegExp(String.raw`\b((?:use|enter|type|input|submit|using)\s+(?:the\s+|this\s+|your\s+)?(?:(?:${Gu})\s+)?(?:code\s+)?)(\d(?:[ -]?\d){3,7})(?!\d)(?=[^\n]{0,60}\bto\s+(?:verify|confirm|sign|log|authenticate|complete|reset|access|continue|activate|finish)\b)`,"gi"),yhQ=new RegExp(String.raw`^(?:${Gu}\s|(?:code|c[oó]digo)\s+de\s|otp$|passcode$|pass\s?code$)`,"i"),wBQ=String.raw`(?:s\.?i\.?n\.?|social\s+insurance(?:\s+(?:number|no\.?))?|ssn|social\s+security(?:\s+(?:number|no\.?))?|itin|nas|num[eé]ro\s+d['’]assurance\s+sociale)`,fhQ=new RegExp(String.raw`\b(${wBQ})\b([^\n\d]{0,25}?)(\d{3}[ -]?\d{3}[ -]?\d{3}|\d{3}[ -]?\d{2}[ -]?\d{4})(?!\d)`,"gi")});var c3A=W(()=>{h3A();m3A()});var l3A=()=>{};var p3A=W(()=>{c3A();l3A()});function d3A(A){if(!A.length)return null;return[...A].sort((Q,B)=>Q.currency==="CAD"?-1:B.currency==="CAD"?1:BigInt(B.netMinor)>BigInt(Q.netMinor)?1:-1)[0]}function Cu(A){let Q=d3A(A);return Q?aQ(Q.netMinor,Q.currency):"—"}function i3A(A){let Q=d3A(A);return A.filter((B)=>B!==Q).map((B)=>aQ(B.netMinor,B.currency)).join(" · ")}function a3A(A){return A.map((Q)=>vBQ[Q]).join(" ")}function xM(A){return[A.industry,A.websiteDomain].filter(Boolean).join(" · ")}var BuQ,n3A,vBQ;var o3A=W(()=>{iH();p3A();BuQ=new Intl.DateTimeFormat("en-CA",{month:"short",year:"numeric",timeZone:"UTC"});n3A={confirmed:"You chose this category.",rule:"Filed here by a rule Oatmilk learned from your changes.",history:"Most of its purchases are filed here."},vBQ={unconfirmed_profile:"Oatmilk filled in this profile. Check it and confirm.",no_category:"It has no category yet.",lookup_needs_review:"The web lookup was not sure. Look at it yourself."}});function Uu(A){if(typeof A!=="string")return!1;let Q=bBQ.exec(A);if(!Q)return!1;let[,B,E,I]=Q.map(Number);return E>=1&&E<=12&&I>=1&&I<=kBQ(B,E)}function kBQ(A,Q){return new Date(Date.UTC(A,Q,0)).getUTCDate()}function s3A(A){if(!Uu(A))throw RangeError(`Invalid date: ${A}`);let[Q,B,E]=A.split("-").map(Number);return[Q,B,E]}function $u(A){let[Q,B,E]=s3A(A);return`${r3A[B-1]} ${E}, ${Q}`}function xBQ(A){let[,Q,B]=s3A(A);return`${r3A[Q-1]} ${B}`}function Yu(A,Q){return A.slice(0,4)===Q.slice(0,4)?`${xBQ(A)} to ${$u(Q)}`:`${$u(A)} to ${$u(Q)}`}var bBQ,r3A;var Ku=W(()=>{bBQ=/^(\d{4})-(\d{2})-(\d{2})$/,r3A=["Jan","Feb","Mar","Apr","May","Jun","Jul","Aug","Sep","Oct","Nov","Dec"]});var t3A=()=>{};var yM=()=>{};var e3A=W(()=>{t3A();yM()});var fM,Hu,Xu="Trying again";var Zu=W(()=>{fM=["queued","reading","imported","review","duplicate","kept","failed"],Hu={queued:{label:"Queued",tone:"active",description:"Kept. Oatmilk will read its lines shortly."},reading:{label:"Reading",tone:"active",description:"Oatmilk is reading the lines and checking them against the statement's balances."},imported:{label:"Imported",tone:"success",description:"The lines add up to the statement's balances and are in the books."},review:{label:"Needs review",tone:"warning",description:"Nothing was booked from this statement. Its reason says what to do."},duplicate:{label:"Duplicate",tone:"neutral",description:"Another copy of a statement Oatmilk already has. Nothing was booked twice."},kept:{label:"Kept",tone:"neutral",description:"Kept as the original statement."},failed:{label:"Couldn't read",tone:"danger",description:"Reading this statement didn't finish. Read it again, or keep it as a record."}}});var ANA=()=>{};var QNA=W(()=>{Ku();e3A();yM();Zu();ANA();yM()});function hM(A){if(A.accountName)return A.lastFour?`${A.accountName} ending ${A.lastFour}`:A.accountName;return A.lastFour?`Account ending ${A.lastFour}, not matched`:"Account not chosen"}function uM(A){if(A.periodStart&&A.periodEnd)return Yu(A.periodStart,A.periodEnd);return A.status==="queued"||A.status==="reading"?"Period not read yet":"Period unknown"}function zu(A){if(A.status==="failed"&&A.statusLabel===Xu)return"active";return Hu[A.status].tone}var cuQ,luQ,Nu;var BNA=W(()=>{QNA();Zu();Ku();cuQ=[...fM,"attention","check"],luQ=[{value:"",label:"Any status"},{value:"check",label:"Needs a check"},{value:"attention",label:"Needs attention"},...fM.map((A)=>({value:A,label:Hu[A].label}))];Nu={upload:"Uploaded",wise:"From Wise",csv:"CSV export"}});var INA;var ENA=W(()=>{INA=["banking","transactions","budgets","inbox","invoices","reimbursements","agreements","contractors","recruiting","tax","compliance","subscriptions","access","settings","other"]});function Fu(A){return qu[A].label}var qu,mBQ,ruQ,DNA;var JNA=W(()=>{ch();ENA();qu={banking:{label:"Banking",prefixes:["imports.","statements.","transactions.","wise.","accounts.","reconciliation.","stripe.","cards.","exchangeRates."]},transactions:{label:"Transactions",prefixes:["entries.","autopilot.","matching.","categories.","tags.","merchants.","trips.","places.","investigations.","holds.","receipt.","summaries.","evidence.","review.","vendor.","folio.","maintenance.","proposals.","attention.","investigator."]},budgets:{label:"Budgets",prefixes:["budgets."]},inbox:{label:"Inbox and records",prefixes:["mail.","mailboxes.","submissions.","uploads.","intake.","documents.","emails.","inbox.","jobs.","documentRequests.","requests.","chase."]},invoices:{label:"Invoices",prefixes:["invoices.","parties.","paymentMethods."]},reimbursements:{label:"Reimbursements",prefixes:["reimbursements."]},agreements:{label:"Agreements",prefixes:["signing.","documents.content.","documents.comments.","documents.assets.","documents.snippets.","documents.suggestions.","documents.history."]},contractors:{label:"Contractors",prefixes:["contractors.","contractorOps.","portal.","invitation."]},recruiting:{label:"Recruiting",prefixes:["recruiting."]},tax:{label:"Tax and reports",prefixes:["tax.","company.","handoff.","reports.","insights.","stripe.year.","investigator.financialIssue"]},compliance:{label:"Compliance",prefixes:["compliance.","calendar.","complianceResearch.","complianceLibrary.","compliancePortal."]},subscriptions:{label:"Subscriptions",prefixes:["subscriptions."]},access:{label:"Team and access",prefixes:["team.","members.","accountants.","accountant.","api_keys.","identity.","senders."]},settings:{label:"Settings and connections",prefixes:["settings.","platform.","connectors.","webhooks.","notion.","dataSources.","dataImports.","ai.","classifier.","memory.","agents.","chiefOfStaff.","onboarding.","notifications.","experiments.","workspace.","email.","company.export","company.close"]},other:{label:"Other",prefixes:[]}},mBQ=INA.flatMap((A)=>qu[A].prefixes.map((Q)=>[Q,A])).sort((A,Q)=>Q[0].length-A[0].length||A[0].localeCompare(Q[0])),ruQ=mBQ.map(([A,Q])=>[A,qu[Q].label]);DNA={web:"Oatmilk",assistant:"Ask AI",mcp:"AI app",api:"API",automation:"Automatic",portal:"Portal",signer:"Signer"}});var GNA=()=>{};var CNA=W(()=>{GNA()});function cBQ(A){return A.normalize("NFKD").replace(/[\u0300-\u036f]/g,"").toLowerCase().replace(/&/g," and ").replace(/[^a-z0-9]+/g," ").trim()}var $NA,BmQ,ImQ;var Mu=W(()=>{$NA=[{key:"income",name:"Sales & services",description:"Money earned from customers: services, sponsorships, tickets and product sales.",keywords:["revenue","sales","income","invoice","client payment","customer payment","earnings"],gifi:"8000",irs:"Schedule C line 1 · Form 1120 line 1a"},{key:"income_services",parent:"income",name:"Services & consulting",description:"Fees for services, consulting and client work.",keywords:["services","consulting","client work","retainer","project fee"],gifi:"8000"},{key:"income_sponsorships",parent:"income",name:"Sponsorships",description:"Money from sponsors and partners in exchange for promotion.",keywords:["sponsorship","sponsor","partner","partnership"],gifi:"8000",notes:"Sponsors paying for exposure buy promotion services from you, so it is a sale."},{key:"income_tickets",parent:"income",name:"Ticket sales",description:"Ticket and registration sales for events.",keywords:["ticket","registration","admission","eventbrite","luma"],gifi:"8000"},{key:"income_products",parent:"income",name:"Product sales",description:"Sales of physical or digital products.",keywords:["product","store","shop","ecommerce","merchandise sales"],gifi:"8000"},{key:"grants",name:"Grants & subsidies",description:"Government grants and assistance, such as IRAP.",keywords:["grant","subsidy","irap","government assistance","funding","wage subsidy"],gifi:"8242",notes:"Government assistance can reduce the related expense claims, such as SR&ED."},{key:"interest_income",name:"Interest income",description:"Interest earned on bank balances and savings.",keywords:["interest","dividend","savings","gic"],gifi:"8090",notes:"Interest from foreign sources goes on line 8091."},{key:"other_income",name:"Other income",description:"Income that fits no other line.",keywords:["other income","miscellaneous income"],gifi:"8230"},{key:"fx_gains",name:"Foreign exchange gains/losses",description:"Gains and losses from converting between currencies.",keywords:["fx","foreign exchange","currency exchange","exchange gain","exchange loss","conversion"],gifi:"8231"},{key:"event_production",name:"Event production",description:"Direct costs of producing the events the organization runs, such as hackathons, meetups and conferences.",keywords:["event","hackathon","meetup","conference","summit","production","demo day"],gifi:"8370",deduction:"full",notes:"Direct event costs are part of cost of sales for an organization that runs events."},{key:"event_venue",parent:"event_production",name:"Venue & rentals",description:"Venue rental, event space and rented equipment for events.",keywords:["venue","event space","room rental","hall","av rental","equipment rental","tent"],gifi:"8910",notes:"Rented equipment goes on line 8914."},{key:"event_catering",parent:"event_production",name:"Food & catering for attendees",description:"Food and drinks served to event attendees.",keywords:["catering","caterer","pizza","food for attendees","refreshments","snacks","drinks"],gifi:"9135",deduction:"meals_50",itc:"half",notes:"Fully deductible when attendees pay (tickets include food): ITA 67.1(2)(a); ask your accountant for free sponsor-funded events."},{key:"event_prizes",parent:"event_production",name:"Prizes & awards",description:"Prizes, awards and stipends paid to participants.",keywords:["prize","award","stipend","bounty","winner","honorarium","gift card"],gifi:"8520",slips:["t4a_028","1099_misc"],notes:"Awards over $500 to people who aren't employees go on a T4A (box 028). If US reporting applies, certain Form 1099-MISC payments use a $2,000 threshold for tax years beginning after 2025; payer and recipient rules still matter."},{key:"event_supplies",parent:"event_production",name:"Supplies & production",description:"Materials, badges, signage, decor and other supplies used to put on events.",keywords:["supplies","badges","lanyards","decor","signage","production supplies"],gifi:"9130"},{key:"event_staff",parent:"event_production",name:"Event staff & vendors",description:"Photographers, AV crews, security and other vendors working an event.",keywords:["photographer","videographer","av","security","event staff","vendor","dj","crew"],gifi:"8360",slips:["t4a_048","1099_nec"],notes:"Fees over $500 a year go on a T4A (box 048). If US reporting applies, certain Form 1099-NEC payments use a $2,000 threshold for tax years beginning after 2025; payer and recipient rules still matter."},{key:"advertising",name:"Advertising & promotion",description:"Advertising, promotion and sponsorships the company pays for.",keywords:["marketing","advertising","promotion","branding","campaign"],gifi:"8520",irs:"Schedule C line 8 · Form 1120 line 22",deduction:"full"},{key:"advertising_ads",parent:"advertising",name:"Advertising",description:"Paid ads on search, social, podcasts and other media.",keywords:["ads","ad","google ads","facebook ads","meta ads","linkedin ads","promoted post","ppc","sponsored post"],gifi:"8521"},{key:"advertising_promotion",parent:"advertising",name:"Promotion & merchandise",description:"Swag, booths, samples and printing.",keywords:["swag","merch","merchandise","t-shirt","stickers","booth","samples","printing","print","banner","business cards"],gifi:"8524"},{key:"advertising_sponsorships",parent:"advertising",name:"Sponsorships you pay",description:"Sponsoring other organizations' events or programs for exposure.",keywords:["sponsorship","sponsor","sponsoring"],gifi:"8520"},{key:"meals",name:"Meals & entertainment (50%)",description:"Business meals and entertainment.",keywords:["meal","lunch","dinner","breakfast","restaurant","coffee","food","drinks","entertainment"],gifi:"8523",irs:"Schedule C line 24b",deduction:"meals_50",itc:"half",notes:"50% deductible (ITA 67.1), and half the GST/HST is claimed back (ETA s.236)."},{key:"meals_client",parent:"meals",name:"Client & business meals",description:"Meals with clients, partners or prospects.",keywords:["client lunch","client dinner","business lunch","business dinner","business meal"],irs:"Schedule C line 24b (50%)"},{key:"meals_travel",parent:"meals",name:"Travel meals",description:"Meals while travelling on business.",keywords:["travel meal","per diem","meals on trip"],irs:"Schedule C line 24b"},{key:"meals_entertainment",parent:"meals",name:"Entertainment",description:"Tickets, shows and outings with clients.",keywords:["entertainment","tickets","concert","game","show","outing","golf"],notes:"50% deductible in Canada. The IRS allows 0% for entertainment."},{key:"staff_events",name:"Staff events & team building",description:"Team events, holiday parties and team building open to all staff.",keywords:["team building","offsite","holiday party","team event","staff party","team lunch","retreat"],gifi:"8620",deduction:"staff_event_full",itc:"full",notes:"Up to 6 events a year open to all employees at a location are fully deductible (ITA 67.1(2)(f)); no taxable benefit up to $150 per person incl. tax (CRA policy). IRS: 100% (§274(e)(4)) if not favouring highly paid staff; contractors don't count."},{key:"contractors",name:"Contractors & freelancers",description:"Freelancers, consultants and contractors paid for their services.",keywords:["contractor","freelancer","freelance","consultant","subcontractor","outsourcing","upwork","developer","designer"],gifi:"9110",irs:"Schedule C line 11",deduction:"full",slips:["t4a_048","t4a_nr","1099_nec"],notes:"Fees for services over $500 a year go on a T4A (box 048); non-residents working in Canada get a T4A-NR, with 15% withheld. If US reporting applies, certain Form 1099-NEC payments use a $2,000 threshold for tax years beginning after 2025; payer and recipient rules still matter."},{key:"salaries",name:"Salaries & wages",description:"Employee pay, including vacation pay and bonuses.",keywords:["salary","wages","payroll","bonus","vacation pay"],gifi:"9060",irs:"Schedule C line 26 · Form 1120 line 13",deduction:"full",itc:"none"},{key:"benefits",name:"Employee benefits",description:"Health plans, group insurance and the employer's share of payroll contributions.",keywords:["benefits","health plan","group insurance","cpp","ei","pension"],gifi:"8620",irs:"Schedule C line 14 · Form 1120 line 24",deduction:"full",notes:"Group insurance goes on line 8621 and the employer's portion of CPP, EI and similar on 8622."},{key:"professional_fees",name:"Professional fees",description:"Lawyers, accountants, consultants and other professional advisers.",keywords:["professional","adviser","advisor"],gifi:"8860",irs:"Schedule C line 17",deduction:"full"},{key:"legal_fees",parent:"professional_fees",name:"Legal fees",description:"Lawyers, notaries and legal work.",keywords:["lawyer","legal","attorney","notary","law firm","trademark","patent","counsel","contract review"],gifi:"8861"},{key:"accounting_fees",parent:"professional_fees",name:"Accounting & bookkeeping",description:"Bookkeeping, accounting, audit and tax preparation.",keywords:["accountant","accounting","bookkeeping","bookkeeper","audit","tax prep","tax preparation","cpa"],gifi:"8862"},{key:"consulting_fees",parent:"professional_fees",name:"Consulting fees",description:"Consultants and advisers the company hires.",keywords:["consultant","consulting","advisory","strategy"],gifi:"8863"},{key:"management_fees",parent:"professional_fees",name:"Management & admin fees",description:"Management or administration services.",keywords:["management fee","admin fee","administration"],gifi:"8871"},{key:"software",name:"Software & computer services",description:"Software subscriptions, SaaS tools, cloud services and IT.",keywords:["software","saas","subscription","app","cloud","tech","plugin","it services"],gifi:"9150",deduction:"full",notes:"SaaS is an expense; purchased application software is CCA class 12."},{key:"software_ai",parent:"software",name:"AI & APIs",description:"AI models and API usage from model providers.",keywords:["ai","llm","api","gpt","model","inference","tokens","gpu","machine learning"],gifi:"9150"},{key:"software_hosting",parent:"software",name:"Hosting & infrastructure",description:"Servers, hosting, databases, domains and other cloud infrastructure.",keywords:["hosting","server","database","domain","dns","cdn","storage","compute","infrastructure","aws","gcp","azure"],gifi:"9150"},{key:"software_subscriptions",parent:"software",name:"Subscriptions & productivity",description:"Workspace tools for email, documents, chat, design and project management.",keywords:["subscription","productivity","collaboration","workspace","email","docs","chat","design","project management","video calls"],gifi:"9150"},{key:"internet",parent:"software",name:"Internet",description:"Internet service.",keywords:["internet","isp","wifi","broadband"],gifi:"9152"},{key:"office",name:"Office expenses",description:"Office costs, supplies and small tools.",keywords:["office"],gifi:"8810",irs:"Schedule C line 18",deduction:"full"},{key:"office_supplies",parent:"office",name:"Office supplies & stationery",description:"Stationery, printer paper and small office supplies.",keywords:["supplies","stationery","paper","pens","printer paper","ink","toner","notebook"],gifi:"8811"},{key:"small_tools",parent:"office",name:"Small tools under $500",description:"Tools and small equipment under $500 each.",keywords:["small tools","tools","accessories","cables","adapters","headphones","webcam","mouse","keyboard"],gifi:"9131"},{key:"capital_equipment",name:"Computer equipment & furniture (capital)",description:"Computers, monitors and furniture the company keeps as assets.",keywords:["laptop","computer","monitor","desk","chair","furniture","hardware","equipment"],gifi:"1774",deduction:"capital",notes:"Computers: CCA class 50 (55%); furniture: class 8 (20%); new immediate-expensing proposals may apply. Furniture and fixtures go on line 1787."},{key:"rent",name:"Rent & coworking",description:"Office rent, coworking and storage.",keywords:["rent","lease","coworking","co-working","office space","storage","desk rental"],gifi:"8910",irs:"Schedule C line 20b · Form 1120 line 16",deduction:"full",notes:"Real estate rental goes on line 8911 and occupancy costs on 8912."},{key:"telephone_utilities",name:"Telephone & utilities",description:"Phone plans, electricity, water and heat.",keywords:["phone","mobile","cell","telecom","utilities","electricity","hydro","water","heat"],gifi:"9225",irs:"Schedule C line 25",deduction:"full",notes:"Utilities such as electricity, water and heat go on line 9220."},{key:"travel",name:"Travel",description:"Business travel: airfare, trains, lodging and ground transportation.",keywords:["travel","trip"],gifi:"9200",irs:"Schedule C line 24a",deduction:"full",notes:"Meals while travelling belong with meals and entertainment."},{key:"travel_air",parent:"travel",name:"Airfare & trains",description:"Flights and train tickets for business trips.",keywords:["flight","airfare","airline","plane","train","rail","baggage"]},{key:"travel_lodging",parent:"travel",name:"Lodging",description:"Hotels, short-term rentals and other accommodation while travelling.",keywords:["hotel","lodging","accommodation","airbnb","motel","hostel","inn"]},{key:"travel_ground",parent:"travel",name:"Ground transportation",description:"Taxis, rideshare, car rental, parking and tolls.",keywords:["taxi","uber","lyft","rideshare","cab","parking","toll","transit","car rental","bus"]},{key:"vehicle",name:"Vehicle expenses",description:"Fuel, repairs, insurance and other costs of company vehicles.",keywords:["vehicle","car","fuel","gas","gasoline","mileage","auto"],gifi:"9281",irs:"Schedule C line 9",deduction:"full"},{key:"conferences",name:"Meetings & conferences",description:"Conferences, conventions and meetings the team attends.",keywords:["conference","convention","summit","meetup","seminar","attend"],gifi:"9201",deduction:"full",notes:"Up to 2 conventions a year (ITA 20(10)); if a fee includes meals without a split, $50/day counts as meals (50%)."},{key:"training",name:"Training & education",description:"Courses, certifications and staff training.",keywords:["training","course","education","learning","certification","workshop","bootcamp"],gifi:"8876",deduction:"full"},{key:"licences",name:"Licences, dues & memberships",description:"Business licences, memberships, government fees and business taxes.",keywords:["licence","license","permit","dues","membership"],gifi:"8760",irs:"Schedule C line 23",deduction:"full"},{key:"memberships",parent:"licences",name:"Professional & trade memberships",description:"Dues for professional bodies, associations and chambers of commerce.",keywords:["membership","dues","association","chamber of commerce"],gifi:"8761"},{key:"government_fees",parent:"licences",name:"Government fees & corporate filings",description:"Incorporation, annual returns, registry and other government filing fees.",keywords:["incorporation","annual return","filing","registry","government fee","registration fee"],gifi:"8764"},{key:"business_taxes",parent:"licences",name:"Business taxes",description:"Business and property taxes charged by municipalities.",keywords:["business tax","municipal tax","property tax"],gifi:"8762"},{key:"insurance",name:"Insurance",description:"Business insurance premiums.",keywords:["insurance","premium","liability","cyber insurance"],gifi:"8690",deduction:"full",itc:"exempt"},{key:"bank_fees",name:"Bank & payment processing fees",description:"Bank, card, wire, currency conversion and payment processing fees.",keywords:["bank fee","bank charge","service charge","wire","wire fee","wise fee","stripe fee","fx fee","card fee","processing fee","transaction fee","monthly fee","nsf","overdraft"],gifi:"8715",deduction:"full",itc:"exempt",notes:"Credit card charges go on line 8716. Financial services carry no GST/HST."},{key:"interest_expense",name:"Interest expense",description:"Interest on loans, lines of credit and credit cards.",keywords:["interest","loan interest","credit card interest","line of credit"],gifi:"8710",irs:"Form 1120 line 18",deduction:"full",itc:"exempt",notes:"Short-term debt goes on line 8711 and long-term debt on 8714."},{key:"repairs",name:"Repairs & maintenance",description:"Repairs and upkeep of equipment and premises.",keywords:["repair","maintenance","fix","service call"],gifi:"8960",deduction:"full"},{key:"shipping",name:"Shipping & delivery",description:"Shipping, courier, freight and postage.",keywords:["shipping","courier","freight","delivery","postage","canada post","fedex","ups","dhl"],gifi:"9275",deduction:"full"},{key:"research",name:"Research & development",description:"Research and development work and materials.",keywords:["research","r&d","sr&ed","experiment","prototype"],gifi:"9282",deduction:"full",notes:"Track SR&ED work and costs for form T661."},{key:"bad_debts",name:"Bad debts",description:"Customer balances written off as uncollectible.",keywords:["bad debt","write-off","uncollectible"],gifi:"8590",deduction:"full"},{key:"donations",name:"Donations",description:"Gifts to registered charities.",keywords:["donation","charity","charitable","gift"],gifi:"8522",deduction:"non_deductible",itc:"none",notes:"Not an expense for a corporation: claimed on Schedule 2. IRS: Form 1120 line 19, capped at 10% of taxable income."},{key:"non_deductible",name:"Non-deductible",description:"Costs the tax rules don't allow: fines, club dues and political contributions.",keywords:["non-deductible","not deductible"],gifi:"9270",deduction:"non_deductible",itc:"none",notes:"Added back on Schedule 1."},{key:"fines",parent:"non_deductible",name:"Fines & penalties",description:"Fines and penalties, such as parking tickets and tax penalties.",keywords:["fine","penalty","parking ticket","speeding ticket"],notes:"Not deductible (ITA 67.6; IRS §162(f)).",sources:["ita-fines"]},{key:"club_dues",parent:"non_deductible",name:"Club dues",description:"Dining, recreation and sports club memberships.",keywords:["club dues","golf club","country club","gym membership","dining club"],notes:"Not deductible (ITA 18(1)(l)), and the GST/HST can't be claimed (ETA 170(1)(a)).",sources:["ita-club-dues","cra-itc-club-dues"]},{key:"political_contributions",parent:"non_deductible",name:"Political contributions",description:"Contributions to political parties and candidates.",keywords:["political","campaign contribution","party donation"],notes:"Not deductible for a business."},{key:"other",name:"Other expenses",description:"Expenses that fit no other category.",keywords:["misc","miscellaneous","other","general"],gifi:"9270",deduction:"full"},{key:"sales_tax_remittances",name:"Sales tax remittances",description:"GST/HST and other sales tax paid to the government.",keywords:["gst","hst","qst","pst","sales tax","remittance","cra payment"],gifi:"2680",deduction:"not_expense",notes:"GST/HST paid to the CRA isn't an expense; it settles the tax you collected."},{key:"income_tax_payments",name:"Income tax payments & instalments",description:"Corporate income tax payments and instalments.",keywords:["income tax","corporate tax","instalment","installment","t2 balance"],gifi:"2680",deduction:"not_expense",notes:"Income tax is not an expense in profit and loss."},{key:"shareholder",name:"Due to/from shareholder",description:"Personal spending paid by the company, and reimbursements to or from owners.",keywords:["shareholder","owner","director","personal","reimbursement","shareholder loan","draw"],gifi:"2780",deduction:"not_expense",notes:"Tracks what the company and its owners owe each other. Use line 1300 when the shareholder owes the company."}],BmQ=new Map($NA.map((A)=>[A.key,A]));ImQ=new Map($NA.map((A)=>[cBQ(A.name),A]))});var oA=(A,Q,B,E)=>({code:A,label:Q,section:B,hint:E}),UNA,KmQ,HmQ;var YNA=W(()=>{Mu();UNA=[oA("8000","Trade sales of goods and services","revenue","Your main sales and service income"),oA("8090","Investment revenue","revenue","Interest and dividends earned"),oA("8091","Interest from foreign sources","revenue","Interest earned outside Canada"),oA("8230","Other revenue","revenue","Income that fits no other line"),oA("8231","Foreign exchange gains/losses","revenue","Currency exchange gains; a loss is shown as a negative amount"),oA("8241","Consulting fees","revenue","Consulting income that is not your main business"),oA("8242","Subsidies and grants","revenue","Government grants and assistance"),oA("8320","Purchases/cost of materials","cost_of_sales","Goods and materials you resell or build into products"),oA("8340","Direct wages","cost_of_sales","Wages counted in cost of sales"),oA("8360","Trades and sub-contracts","cost_of_sales","Contract labour counted in cost of sales"),oA("8370","Production costs other than resource","cost_of_sales","Direct costs of producing what you sell, such as events you run"),oA("8520","Advertising and promotion","operating_expenses","Marketing, ads and promotion"),oA("8521","Advertising","operating_expenses","Ads and paid media"),oA("8522","Donations","operating_expenses","Charitable and political donations"),oA("8523","Meals and entertainment","operating_expenses","Business meals and entertainment"),oA("8524","Promotion","operating_expenses","Events, booths, displays and samples you provide"),oA("8590","Bad debt expense","operating_expenses","Customer balances written off"),oA("8620","Employee benefits","operating_expenses","Staff benefits and payroll levies"),oA("8621","Group insurance benefits","operating_expenses","Group health and insurance plans for staff"),oA("8622","Employer's portion of employee benefits","operating_expenses","The employer's share of CPP, EI and similar"),oA("8690","Insurance","operating_expenses","Business insurance premiums"),oA("8710","Interest and bank charges","operating_expenses","Loan interest and financing charges"),oA("8711","Interest on short-term debt","operating_expenses","Interest on loans due within a year"),oA("8714","Interest on long-term debt","operating_expenses","Interest on loans due after a year"),oA("8715","Bank charges","operating_expenses","Bank and payment processing fees"),oA("8716","Credit card charges","operating_expenses","Fees for accepting credit cards"),oA("8760","Business taxes, licences, and memberships","operating_expenses","Licences, permits and business taxes"),oA("8761","Memberships","operating_expenses","Association dues and subscriptions"),oA("8762","Business taxes","operating_expenses","Business and property taxes"),oA("8764","Government fees","operating_expenses","Filing and registry fees paid to governments"),oA("8810","Office expenses","operating_expenses","Office costs and small equipment"),oA("8811","Office stationery and supplies","operating_expenses","Stationery and office supplies"),oA("8860","Professional fees","operating_expenses","Professional services"),oA("8861","Legal fees","operating_expenses","Lawyers and notaries"),oA("8862","Accounting fees","operating_expenses","Accounting and bookkeeping"),oA("8863","Consulting fees","operating_expenses","Consultants and advisers you hire"),oA("8871","Management and administration fees","operating_expenses","Management or administration services"),oA("8876","Training expense","operating_expenses","Courses and staff training"),oA("8910","Rental","operating_expenses","Other rentals, such as parking or storage"),oA("8911","Real estate rental","operating_expenses","Office or building rent"),oA("8912","Occupancy costs","operating_expenses","Costs of occupying premises, beyond rent"),oA("8914","Equipment rental","operating_expenses","Rented equipment and machines"),oA("8960","Repairs and maintenance","operating_expenses","Repairs and upkeep"),oA("9060","Salaries and wages","operating_expenses","Employee pay not counted in cost of sales"),oA("9110","Sub-contracts","operating_expenses","Contractors and freelancers"),oA("9130","Supplies","operating_expenses","Supplies used in the business"),oA("9131","Small tools","operating_expenses","Tools and small equipment used up quickly"),oA("9135","Food and catering","operating_expenses","Food and catering you provide"),oA("9150","Computer-related expenses","operating_expenses","Software, cloud services and IT"),oA("9152","Internet","operating_expenses","Internet service"),oA("9200","Travel expenses","operating_expenses","Flights, hotels and business travel"),oA("9201","Meetings and conventions","operating_expenses","Conferences and events you attend"),oA("9220","Utilities","operating_expenses","Electricity, water and heat"),oA("9225","Telephone and telecommunications","operating_expenses","Phone and mobile plans"),oA("9270","Other expenses","operating_expenses","Expenses that fit no other line"),oA("9275","Delivery, freight and express","operating_expenses","Shipping and courier"),oA("9281","Vehicle expenses","operating_expenses","Fuel, repairs and other vehicle costs"),oA("9282","Research and development","operating_expenses","Research and development costs"),oA("1001","Cash","assets","Cash on hand"),oA("1002","Deposits in Canadian banks and institutions – Canadian currency","assets","Canadian-dollar bank balances"),oA("1003","Deposits in Canadian banks and institutions – Foreign currency","assets","Foreign-currency balances at Canadian banks"),oA("1060","Accounts receivable","assets","Amounts customers owe you"),oA("1066","Taxes receivable","assets","GST/HST and income tax refunds owed to you"),oA("1300","Due from shareholder(s)/director(s)","assets","Amounts owners or directors owe the company"),oA("1484","Prepaid expenses","assets","Costs paid ahead for a later period"),oA("1740","Machinery, equipment, furniture, and fixtures","assets","Equipment and furniture kept as assets"),oA("1774","Computer equipment/software","assets","Computers and software kept as assets"),oA("1787","Furniture and fixtures","assets","Furniture and fixtures kept as assets"),oA("2620","Amounts payable and accrued liabilities","liabilities","Bills and costs you still owe"),oA("2621","Trade payables","liabilities","Supplier invoices you still owe"),oA("2680","Taxes payable","liabilities","GST/HST and income taxes owed"),oA("2780","Due to shareholder(s)/director(s)","liabilities","Amounts the company owes its owners or directors"),oA("3500","Common shares","equity","Share capital"),oA("3600","Retained earnings/deficit","equity","Profits kept in the company over the years"),oA("3700","Dividends declared","equity","Dividends paid or declared to shareholders")],KmQ=UNA.map((A)=>A.code),HmQ=new Map(UNA.map((A)=>[A.code,A]))});var KNA=W(()=>{Mu();YNA()});var SB="https://www.canada.ca/en/revenue-agency/services",lBQ;var HNA=W(()=>{lBQ={"cra-authorize-representative":{id:"cra-authorize-representative",title:"CRA: authorize a representative",authority:"CRA",jurisdiction:"CA",url:"https://www.canada.ca/en/revenue-agency/services/tax/representative-authorization/overview.html",snippet:"A representative needs authorization to access your tax information. Accountant workspace access does not grant CRA representation.",status:"in_force",details:[{label:"Authorization",value:"The taxpayer authorizes the representative through CRA."},{label:"Workspace access",value:"An Oatmilk invitation grants no access to CRA accounts."}]},"cra-meals-50":{id:"cra-meals-50",title:"Meals and entertainment: 50% limit",authority:"CRA",jurisdiction:"CA",reference:"ITA 67.1",status:"in_force",url:`${SB}/tax/businesses/topics/sole-proprietorships-partnerships/report-business-income-expenses/completing-form-t2125/line-8523-meals-entertainment-allowable-part-only.html`,snippet:"Only half of what a business spends on food, drinks and entertainment can be deducted.",details:[{label:"Deduction",value:"50% of the cost"},{label:"Exceptions",value:"Food sold to customers, and up to six all-staff events a year"}]},"cra-staff-events":{id:"cra-staff-events",title:"All-staff events: six a year fully deductible",authority:"CRA",jurisdiction:"CA",reference:"ITA 67.1(2)(f)",status:"in_force",url:`${SB}/tax/businesses/topics/payroll/benefits-allowances/social.html`,snippet:"Up to six events a year open to all employees at a location are exempt from the 50% limit. There is no taxable benefit when the cost is $150 or less per person.",details:[{label:"Deduction",value:"100%, for up to six events a year"},{label:"Benefit",value:"None up to $150 per person, tax included"}]},"cra-input-tax-credits":{id:"cra-input-tax-credits",title:"What is an input tax credit (ITC)?",authority:"CRA",jurisdiction:"CA",status:"in_force",url:`${SB}/tax/businesses/topics/gst-hst-businesses/calculate-prepare-report/input-tax-credit.html`,snippet:"An input tax credit (ITC) lets a GST/HST-registered business recover eligible GST/HST paid or owed on business purchases. The amount you can claim depends on commercial use and supporting documents.",details:[{label:"Claimed on",value:"GST/HST return"}]},"cra-itc-meals-50":{id:"cra-itc-meals-50",title:"GST/HST on meals: half the credit",authority:"CRA",jurisdiction:"CA",reference:"ETA s.236",status:"in_force",url:`${SB}/forms-publications/publications/8-2/general-restrictions-limitations.html`,snippet:"When only half of a meal or entertainment cost is deductible, half of the input tax credits claimed on it are paid back.",details:[{label:"GST/HST credit",value:"50% of the tax paid"}]},"cra-itc-club-dues":{id:"cra-itc-club-dues",title:"Club dues: no GST/HST credit",authority:"CRA",jurisdiction:"CA",reference:"ETA 170(1)(a)",status:"in_force",url:`${SB}/forms-publications/publications/8-2/general-restrictions-limitations.html`,snippet:"No input tax credit can be claimed on memberships in dining, sports or recreation clubs.",details:[{label:"GST/HST credit",value:"None"}]},"ita-club-dues":{id:"ita-club-dues",title:"Club dues: not deductible",authority:"Justice Canada",jurisdiction:"CA",reference:"ITA 18(1)(l)",status:"in_force",url:"https://laws-lois.justice.gc.ca/eng/acts/I-3.3/section-18.html",snippet:"Membership fees for clubs whose main purpose is dining, recreation or sport can't be deducted.",details:[{label:"Deduction",value:"None"}]},"ita-fines":{id:"ita-fines",title:"Fines and penalties: not deductible",authority:"Justice Canada",jurisdiction:"CA",reference:"ITA 67.6",status:"in_force",url:"https://laws-lois.justice.gc.ca/eng/acts/I-3.3/section-67.6.html",snippet:"Fines and penalties imposed under a law can't be deducted.",details:[{label:"Deduction",value:"None"}]},"cra-itc-documents":{id:"cra-itc-documents",title:"Receipts needed for GST/HST credits",authority:"CRA",jurisdiction:"CA",reference:"ETA 169(4)",status:"in_force",url:`${SB}/forms-publications/publications/8-4/documentary-requirements-claiming-input-tax-credits.html`,snippet:"An input tax credit needs a supporting document with the details the rules require. Without a receipt, no credit is claimed.",details:[{label:"Without a receipt",value:"No GST/HST credit"},{label:"More detail needed",value:"As the purchase amount grows"}]},"cra-foreign-currency-rate":{id:"cra-foreign-currency-rate",title:"Amounts in another currency: Bank of Canada rate",authority:"CRA",jurisdiction:"CA",reference:"Income Tax Folio S5-F4-C1; ITA 261(1)",status:"in_force",url:`${SB}/tax/technical-information/income-tax/income-tax-folios-index/series-5-international-residency/series-5-international-residency-folio-4-foreign-currency/income-tax-folio-s5-f4-c1-income-tax-reporting-currency.html`,snippet:"Amounts in another currency are converted to Canadian dollars at the Bank of Canada rate for the day, or at another rate the CRA accepts.",details:[{label:"Rate",value:"Bank of Canada daily rate for the transaction day"},{label:"No rate that day",value:"The closest earlier day with a published rate"},{label:"Also accepted",value:"Another rate acceptable to the CRA"}]},"cra-imported-services":{id:"cra-imported-services",title:"Services from a company outside Canada",authority:"CRA",jurisdiction:"CA",reference:"ETA Division IV",status:"in_force",url:`${SB}/tax/businesses/topics/gst-hst-businesses/charge-collect-imports-exports.html`,snippet:"A company outside Canada that isn't registered doesn't charge GST/HST. A registrant that uses the service 90% or more in its commercial activities has nothing to self-assess.",details:[{label:"Charged by the supplier",value:"No Canadian GST/HST"},{label:"Self-assess when",value:"Used less than 90% in commercial activities"},{label:"Return line",value:"405"}]},"cra-reimbursement-itc":{id:"cra-reimbursement-itc",title:"GST/HST on reimbursed expenses",authority:"CRA",jurisdiction:"CA",reference:"GST/HST Memorandum 9-4",status:"in_force",url:`${SB}/forms-publications/publications/9-4/reimbursements.html`,snippet:"For section 175, the person must have been an employee or officer when they bought the business expense. The employer is deemed to pay the GST/HST when it reimburses them and needs supporting records for an input tax credit.",details:[{label:"At purchase",value:"Employee or officer status must be confirmed"},{label:"Receipt",value:"Required details must be verified"},{label:"Timing",value:"Claim after the reimbursement is paid"}]},"cra-t4a-048":{id:"cra-t4a-048",title:"T4A box 048: fees for services and CRA reporting policy",authority:"CRA",jurisdiction:"CA",reference:"T4A box 048",status:"in_force",url:`${SB}/tax/businesses/topics/payroll/completing-filing-information-returns/t4a-information-payers/t4a-slip.html`,snippet:"Report fees for services, excluding GST/HST/PST. CRA administrative policy calls for a T4A when annual fees exceed $500 or tax was deducted. From 2025, the penalty policy targets trucking businesses paying a trucking CCPC over $500.",details:[{label:"Box 048",value:"Report fees for services; exclude GST/HST and PST"},{label:"Administrative policy",value:"More than $500 in the calendar year, or tax was deducted"},{label:"2025+ penalty policy",value:"Trucking business paying a trucking CCPC more than $500"},{label:"Due",value:"Last day of February"}]},"cra-t4a-028":{id:"cra-t4a-028",title:"T4A box 028: prizes and awards",authority:"CRA",jurisdiction:"CA",reference:"T4A box 028",status:"in_force",url:`${SB}/tax/businesses/topics/payroll/completing-filing-information-returns/t4a-information-payers/t4a-slip.html`,snippet:"Prizes and awards to people who aren't employees go in box 028 of a T4A when they total more than $500 in the year.",details:[{label:"Threshold",value:"More than $500 a year"}]},"cra-t4a-recipient":{id:"cra-t4a-recipient",title:"T4A recipient: SIN, business number and address",authority:"CRA",jurisdiction:"CA",reference:"T4A boxes 012 and 013",status:"in_force",url:`${SB}/tax/businesses/topics/payroll/completing-filing-information-returns/t4a-information-payers/t4a-slip/filling-t4a-slip.html`,snippet:"Box 012 takes the recipient's SIN; a business recipient's business number goes in box 013 instead. The slip needs their home address with the province or territory, postal code and country.",details:[{label:"Box 012",value:"Social insurance number"},{label:"Box 013",value:"Business number, like 123456789RT0001"},{label:"Address",value:"Province or territory, postal code and country"},{label:"Name",value:"Last name, first name and initials; for a business, its legal or operating name"},{label:"Box 061",value:"The payer's 15-character payroll account number, like 123456789RP0001"}]},"cra-t4a-filing":{id:"cra-t4a-filing",title:"CRA: how to file T4A slips and the T4A Summary",authority:"CRA",jurisdiction:"CA",reference:"How to file information returns",status:"in_force",url:`${SB}/tax/businesses/topics/payroll/file-information-returns-slip-summaries/how-to-file.html`,snippet:"With more than 5 T4A slips for a year, you must file electronically: Web Forms (up to 100 slips, with the summary totals worked out for you) or Internet file transfer of an XML file. Otherwise paper is allowed.",details:[{label:"File electronically",value:"More than 5 slips of one type for a calendar year"},{label:"Web Forms",value:"Up to 100 slips; summary totals are calculated for you"},{label:"Internet file transfer",value:"An XML file from payroll or other software, up to 150 MB"},{label:"Paper",value:"Only when electronic filing isn't required; each slip goes with the summary"},{label:"Penalty",value:"From $125 for 6 to 50 slips not filed electronically"}]},"cra-t4a-distribute":{id:"cra-t4a-distribute",title:"CRA: give recipients their slips by the last day of February",authority:"CRA",jurisdiction:"CA",reference:"Distribute the slips",status:"in_force",url:`${SB}/tax/businesses/topics/payroll/file-information-returns-slip-summaries/distribute-slips.html`,snippet:"Give each recipient their slips by the last day of February: 2 copies, in person or by mail. To send slips by email, first get the recipient's consent in writing or electronically.",details:[{label:"Deadline",value:"Last day of February after the calendar year"},{label:"Paper",value:"2 copies of the T4A slip, in person or by mail"},{label:"Email",value:"Needs the recipient's written or electronic consent first"},{label:"Wrong address",value:"Don't mail to an address known to be wrong; note why it wasn't sent"}]},"cra-sin-reasonable-effort":{id:"cra-sin-reasonable-effort",title:"Asking for a SIN for information slips",authority:"CRA",jurisdiction:"CA",reference:"ITA 237(1), 237(2), 162(5); IC82-2R2",status:"in_force",url:`${SB}/forms-publications/publications/ic82-2/social-insurance-number-legislation-that-relates-preparation-information-slips.html`,snippet:"Whoever prepares a slip must make a reasonable effort to get the recipient's SIN and keep a record of when it was asked for. A SIN can't be used or shared for anything else.",details:[{label:"Penalty",value:"$100 for each slip without a SIN, unless a reasonable effort was made"},{label:"Keep",value:"The date of each request"},{label:"Without a SIN",value:"File the slip on time anyway"}]},"cra-t4a-nr":{id:"cra-t4a-nr",title:"T4A-NR: non-residents working in Canada",authority:"CRA",jurisdiction:"CA",reference:"Regulation 105",status:"in_force",url:`${SB}/forms-publications/publications/rc4445/t4a-payments-non-residents-services-provided-canada.html`,snippet:"Payments to non-residents for services done in Canada go on a T4A-NR, whatever the amount, and 15% is withheld unless the CRA approved a waiver.",details:[{label:"Threshold",value:"Any amount"},{label:"Withholding",value:"15%"}]},"cra-reg105-outside-canada":{id:"cra-reg105-outside-canada",title:"CRA: no Regulation 105 withholding for work done outside Canada",authority:"CRA",jurisdiction:"CA",reference:"IC75-6R2, paragraphs 32 and 42",status:"in_force",url:`${SB}/forms-publications/publications/ic75-6/required-withholding-amounts-paid-non-residents-providing-services-canada.html`,snippet:"Payments to non-residents for services performed outside Canada aren't subject to Regulation 105 withholding. Work done partly in Canada needs a reasonable, documented split. The T4A-NR reports amounts for services provided in Canada.",details:[{label:"Work outside Canada",value:"No Regulation 105 withholding"},{label:"Work partly in Canada",value:"Split the payment reasonably and show the split in the contract or records"},{label:"No documented split",value:"Withholding on the whole payment is recommended"},{label:"T4A-NR",value:"Amounts for services provided in Canada, due the last day of February"}]},"irs-1099-threshold":{id:"irs-1099-threshold",title:"Forms 1099-NEC and 1099-MISC: $2,000 from 2026",authority:"IRS",jurisdiction:"US",reference:"Forms 1099-MISC and 1099-NEC instructions",effectiveDate:"2026-01-01",status:"in_force",url:"https://www.irs.gov/instructions/i1099mec",snippet:"From 2026, certain nonemployee compensation and miscellaneous payments have a $2,000 threshold. For a Canadian payer, reporting depends on U.S. rules, service source, payment method and payee status.",details:[{label:"Threshold",value:"$2,000 for certain payments"},{label:"Applies to",value:"Tax years beginning after December 31, 2025"},{label:"Payment cards",value:"Payments reported by a payment settlement entity on Form 1099-K generally aren't reported again by the payer on Form 1099-NEC"},{label:"Caveat",value:"Confirm payer, sourcing and payee rules with a U.S. tax professional"}]},"irs-w9":{id:"irs-w9",title:"IRS Form W-9: request for taxpayer identification number",authority:"IRS",jurisdiction:"US",reference:"Form W-9",status:"in_force",url:"https://www.irs.gov/forms-pubs/about-form-w-9",snippet:"A U.S. person gives Form W-9 to the requester so the requester has the correct taxpayer identification number for an information return. The requester keeps the form; it is not sent to the IRS with the return.",details:[{label:"Who gives it",value:"U.S. persons and entities when requested"},{label:"Where it goes",value:"To the requester, not the IRS"}]},"irs-w8ben":{id:"irs-w8ben",title:"IRS Form W-8BEN: foreign individuals",authority:"IRS",jurisdiction:"US",reference:"Form W-8BEN",status:"in_force",url:"https://www.irs.gov/forms-pubs/about-form-w-8-ben",snippet:"A foreign individual gives Form W-8BEN to the withholding agent or payer to certify foreign status and, where applicable, claim treaty benefits. The form is not sent to the IRS by the payee.",details:[{label:"Who uses it",value:"Foreign individuals, when requested"},{label:"Where it goes",value:"To the withholding agent or payer"}]},"irs-w8bene":{id:"irs-w8bene",title:"IRS Form W-8BEN-E: foreign entities",authority:"IRS",jurisdiction:"US",reference:"Form W-8BEN-E",status:"in_force",url:"https://www.irs.gov/forms-pubs/about-form-w-8-ben-e",snippet:"A foreign entity generally uses Form W-8BEN-E to certify its foreign status to a withholding agent or payer. The correct W-8 form depends on the payee and payment; it is retained by the requester, not filed by the payee with the IRS.",details:[{label:"Who uses it",value:"Foreign entities, when requested"},{label:"Where it goes",value:"To the withholding agent or payer"}]},"irs-services-source":{id:"irs-services-source",title:"IRS Publication 515: source of personal service income",authority:"IRS",jurisdiction:"US",reference:"Publication 515",status:"in_force",url:"https://www.irs.gov/publications/p515",snippet:"Compensation for personal services is generally sourced to where the services are physically performed. A payee's citizenship, mailing address, payment currency and payer's state of incorporation do not, by themselves, establish the source.",details:[{label:"Work in the United States",value:"May create U.S.-source income and withholding or information-reporting questions"},{label:"Work entirely abroad",value:"Usually foreign-source personal service income; confirm exceptions and treaty facts"}]},"irs-1120-deadline":{id:"irs-1120-deadline",title:"IRS Form 1120: C corporation return deadline",authority:"IRS",jurisdiction:"US",reference:"Instructions for Form 1120",status:"in_force",url:"https://www.irs.gov/instructions/i1120",snippet:"A C corporation generally files Form 1120 by the 15th day of the fourth month after the end of its tax year. A corporation with a June 30 year-end generally uses the 15th day of the third month.",details:[{label:"Tax year-end",value:"Due date is based on the tax year-end and federal classification"},{label:"Extensions",value:"An extension to file does not extend time to pay tax"}]},"irs-1120f":{id:"irs-1120f",title:"IRS Form 1120-F: foreign corporation return",authority:"IRS",jurisdiction:"US",reference:"Instructions for Form 1120-F",status:"in_force",url:"https://www.irs.gov/instructions/i1120f",snippet:"A foreign corporation may need a U.S. return based on its U.S. trade or business, effectively connected income and other filing rules. Due dates and exceptions depend on its facts; confirm with a U.S. tax professional.",details:[{label:"Who files",value:"Foreign corporations that meet the return requirements in the instructions"},{label:"Due date",value:"Varies with the company's U.S. presence and filing facts; do not infer from formation state"}]},"irs-1120s-deadline":{id:"irs-1120s-deadline",title:"IRS Form 1120-S: S corporation return deadline",authority:"IRS",jurisdiction:"US",reference:"Instructions for Form 1120-S",status:"in_force",url:"https://www.irs.gov/instructions/i1120s",snippet:"An S corporation generally files Form 1120-S by the 15th day of the third month after the end of its tax year. State requirements and elections are separate.",details:[{label:"Federal filing",value:"15th day of the third month after year-end"},{label:"State filings",value:"Check each relevant state separately"}]},"irs-1065-deadline":{id:"irs-1065-deadline",title:"IRS Form 1065: partnership return deadline",authority:"IRS",jurisdiction:"US",reference:"Instructions for Form 1065",status:"in_force",url:"https://www.irs.gov/instructions/i1065",snippet:"A partnership generally files Form 1065 by the 15th day of the third month after the end of its tax year. The entity's legal form alone does not establish its federal tax classification.",details:[{label:"Federal filing",value:"15th day of the third month after year-end"},{label:"Tax classification",value:"Confirm the IRS classification before scheduling this return"}]},"irs-llc-classification":{id:"irs-llc-classification",title:"IRS: an LLC's federal tax classification",authority:"IRS",jurisdiction:"US",reference:"Limited Liability Company (LLC)",status:"in_force",url:"https://www.irs.gov/businesses/small-businesses-self-employed/limited-liability-company-llc",snippet:"An LLC may be treated as a corporation, partnership or disregarded entity for federal tax purposes, depending on its members and elections. The word LLC does not determine which return to file.",details:[{label:"Default treatment",value:"Depends on the number of owners and elections"},{label:"Oatmilk",value:"Never infers federal tax classification from the legal form"}]},"sba-foreign-qualification":{id:"sba-foreign-qualification",title:"U.S. Small Business Administration: register in other states",authority:"US SBA",jurisdiction:"US",status:"in_force",url:"https://www.sba.gov/business-guide/launch-your-business/register-your-business",snippet:"A company formed in one U.S. state may need to register as a foreign entity before conducting business in another state. Requirements and filings depend on each state and the company's activities.",details:[{label:"Registration",value:"Check every state where the company has relevant activity"},{label:"Annual reports and fees",value:"Deadlines differ by state and entity type"}]},"canada-extra-provincial-registration":{id:"canada-extra-provincial-registration",title:"Corporations Canada: extra-provincial registration",authority:"Government of Canada",jurisdiction:"CA",status:"in_force",url:"https://ised-isde.canada.ca/site/corporations-canada/en/business-corporations/doing-business-canada/extra-provincial-registration",snippet:"A corporation formed federally or in one province may have to register separately before carrying on business in another province or territory. The province or territory determines its own registration tests and filings.",details:[{label:"Formation",value:"Federal incorporation does not register a corporation everywhere in Canada"},{label:"Operations",value:"Track registrations for each province or territory where the corporation operates"}]},"cra-fees-services":{id:"cra-fees-services",title:"CRA: fees and other amounts for services",authority:"CRA",jurisdiction:"CA",reference:"ITA 150(1), 153(1)(g), 162",status:"in_force",url:"https://www.canada.ca/en/revenue-agency/services/tax/businesses/topics/payroll/payroll-deductions-contributions/special-payments/fees-other-amounts-services.html",snippet:"Canadian residents generally get a T4A for service fees over $500, or when tax was deducted. Payments to non-residents for services in Canada generally need a T4A-NR at any amount and 15% withholding unless waived.",details:[{label:"Resident service fees",value:"More than $500 annually under CRA administrative policy, or tax deducted"},{label:"Non-resident service in Canada",value:"T4A-NR at any amount; 15% withholding unless waived"},{label:"Services outside Canada",value:"The T4A fee-for-service instructions include services inside or outside Canada"}]},"irs-1099-nec-deadline":{id:"irs-1099-nec-deadline",title:"IRS Form 1099-NEC: filing deadline",authority:"IRS",jurisdiction:"US",reference:"Instructions for Forms 1099-MISC and 1099-NEC",status:"in_force",url:"https://www.irs.gov/instructions/i1099mec",snippet:"Form 1099-NEC is generally due to the recipient and the IRS by January 31, adjusted to the next business day when the date falls on a weekend or federal holiday.",details:[{label:"Recipient and IRS",value:"January 31, or the next business day"}]},"irs-meals-entertainment":{id:"irs-meals-entertainment",title:"US meals 50%, entertainment 0%, staff recreation 100%",authority:"IRS",jurisdiction:"US",reference:"IRC §274; Publication 463",status:"in_force",url:"https://www.irs.gov/publications/p463",snippet:"Business meals are 50% deductible and entertainment isn't deductible. Recreation and parties mainly for employees are fully deductible under §274(e)(4).",details:[{label:"Meals",value:"50%"},{label:"Entertainment",value:"0%"},{label:"Employee recreation",value:"100%"}]},"cra-cca-classes":{id:"cra-cca-classes",title:"Capital cost allowance: classes 50 and 12",authority:"CRA",jurisdiction:"CA",reference:"CCA classes 8, 12 and 50",status:"in_force",url:`${SB}/tax/businesses/topics/sole-proprietorships-partnerships/report-business-income-expenses/claiming-capital-cost-allowance/classes-depreciable-property.html`,snippet:"Computers are class 50 (55%), application software is class 12 (100%) and furniture is class 8 (20%). They are deducted over time, not as an expense.",details:[{label:"Computers",value:"Class 50, 55%"},{label:"Software",value:"Class 12, 100%"},{label:"Furniture",value:"Class 8, 20%"}]},"fin-immediate-expensing":{id:"fin-immediate-expensing",title:"Proposed: immediate expensing of new investment",authority:"Finance Canada",jurisdiction:"CA",reference:"Proposed measure, September 15, 2026",effectiveDate:"2026-09-15",status:"proposed",url:"https://www.canada.ca/en/department-finance/news/2026/09/government-of-canada-introduces-new-productivity-mega-deduction-to-boost-canadas-advantage-as-the-most-competitive-g7-country-for-new-business-inve.html",snippet:"The government proposes letting businesses deduct the full cost of most new equipment, including computers, in the year it's first used. It isn't law yet.",details:[{label:"Status",value:"Proposed, not yet law"},{label:"Applies to",value:"Assets acquired on or after September 15, 2026"}]},"fin-immediate-expensing-draft":{id:"fin-immediate-expensing-draft",title:"Draft regulations for immediate expensing",authority:"Finance Canada",jurisdiction:"CA",reference:"Draft ITA and Income Tax Regulations, September 2026",effectiveDate:"2026-09-15",status:"proposed",url:"https://www.canada.ca/en/department-finance/corporate/laws-regulations/draft-legislation/2026/09-itaitr-lirrir.html",snippet:"Finance Canada has published draft legislative proposals for broader immediate expensing. These are proposals, so current tax treatment remains unchanged pending enactment and CRA guidance.",details:[{label:"Status",value:"Draft legislation, not an enacted rule"},{label:"Follow-up",value:"Track enactment and CRA guidance before changing tax calculations"}]},"cra-gifi":{id:"cra-gifi",title:"GIFI codes (RC4088)",authority:"CRA",jurisdiction:"CA",reference:"RC4088",status:"in_force",url:`${SB}/forms-publications/publications/rc4088/general-index-financial-information-gifi.html`,snippet:"Corporations report their financial statements to the CRA with GIFI codes, one code per line of the income statement and balance sheet.",details:[{label:"Used for",value:"T2 Schedules 100 and 125"}]},"cra-gifi-guide":{id:"cra-gifi-guide",title:"GIFI: bank charges and how sales are reported",authority:"CRA",jurisdiction:"CA",reference:"RC4088 items 8000, 8710 and 8715",status:"in_force",url:`${SB}/forms-publications/publications/rc4088/general-index-financial-information-gifi.html`,snippet:"In the GIFI, item 8715 is bank charges, part of 8710, interest and bank charges. Item 8000, trade sales of goods and services, may be reported net of discounts, sales rebates, volume discounts, returns and allowances.",details:[{label:"8715",value:"Bank charges"},{label:"8710",value:"Interest and bank charges: finance charges, bank charges and interest on capital leases"},{label:"8000 can be net of",value:"Discounts, sales rebates, volume discounts, returns and allowances"},{label:"Payment processor fees",value:"Not named in the guide; confirm their line with your accountant"}]},"on-job-postings":{id:"on-job-postings",title:"Ontario job postings: pay, vacancy and AI disclosure",authority:"Province",jurisdiction:"CA-ON",reference:"ESA Part III.1, O. Reg. 476/24",status:"in_force",effectiveDate:"2026-01-01",url:"https://www.ontario.ca/document/your-guide-employment-standards-act-0/requirements-related-publicly-advertised-job",snippet:"Ontario employers with 25 or more employees must state the expected pay or pay range, whether a vacancy exists, and any use of AI to screen, assess or select applicants in public job postings.",details:[{label:"Pay range",value:"At most $50,000 wide, unless pay is over $200,000"},{label:"Also",value:"No Canadian experience requirements"},{label:"Applies to",value:"Employers with 25 or more employees"}]},"on-interview-outcome":{id:"on-interview-outcome",title:"Ontario: tell interviewed applicants within 45 days",authority:"Province",jurisdiction:"CA-ON",reference:"ESA Part III.1, O. Reg. 476/24",status:"in_force",effectiveDate:"2026-01-01",url:"https://www.ontario.ca/document/your-guide-employment-standards-act-0/requirements-related-publicly-advertised-job",snippet:"Employers must tell applicants they interviewed for a publicly advertised job whether a hiring decision has been made, within 45 days of the last interview.",details:[{label:"Deadline",value:"45 days after the last interview"},{label:"Applies to",value:"Employers with 25 or more employees"}]},"on-non-compete":{id:"on-non-compete",title:"Ontario: employers can't use non-competes, with two exceptions",authority:"Province",jurisdiction:"CA-ON",reference:"ESA s.67.2",effectiveDate:"2021-10-25",status:"in_force",url:"https://www.ontario.ca/document/your-guide-employment-standards-act-0/non-compete-agreements",snippet:"Employers can't have employees or applicants sign a non-compete. Exceptions: executives, and a seller who becomes an employee after selling a business. The ESA doesn't ban non-solicit or confidentiality clauses.",details:[{label:"Ban",value:"Since October 25, 2021"},{label:"Exceptions",value:"Executives; sale of a business"},{label:"Not banned",value:"Non-solicit and non-disclosure clauses"}]},"on-employee-status":{id:"on-employee-status",title:"Ontario: a contractor label doesn't decide employee status",authority:"Province",jurisdiction:"CA-ON",reference:"ESA s.5.1",status:"in_force",url:"https://www.ontario.ca/document/your-guide-employment-standards-act-0/employee-status",snippet:"The real relationship decides whether someone is an employee, not the label or the contract. Treating an employee as a non-employee can bring a notice of contravention, penalties or prosecution.",details:[{label:"Test",value:"The facts of the relationship"},{label:"Risk",value:"Notice of contravention, penalties or prosecution"}]},"on-vacation":{id:"on-vacation",title:"Ontario vacation: two weeks, three after five years",authority:"Province",jurisdiction:"CA-ON",reference:"ESA ss.33, 35.2, 36",status:"in_force",url:"https://www.ontario.ca/document/your-guide-employment-standards-act-0/vacation",snippet:"Employees earn two weeks of vacation after each vacation year, three weeks after five years, and vacation pay of at least 4% of gross wages (6% after five years).",details:[{label:"Under 5 years",value:"2 weeks, 4% vacation pay"},{label:"5 years or more",value:"3 weeks, 6% vacation pay"}]},"on-termination":{id:"on-termination",title:"Ontario: notice or termination pay after three months",authority:"Province",jurisdiction:"CA-ON",reference:"ESA ss.54, 57, 61",status:"in_force",url:"https://www.ontario.ca/document/your-guide-employment-standards-act-0/termination-employment",snippet:"After three months of continuous employment, ending employment needs written notice, termination pay instead, or a mix, unless an exemption applies. Notice grows from one week to eight weeks with years of service.",details:[{label:"Notice",value:"1 week up to 8 weeks"},{label:"Severance pay",value:"A separate, narrower entitlement"}]},"on-overtime":{id:"on-overtime",title:"Ontario overtime: time and a half after 44 hours",authority:"Province",jurisdiction:"CA-ON",reference:"ESA s.22",status:"in_force",url:"https://www.ontario.ca/document/your-guide-employment-standards-act-0/overtime-pay",snippet:"Most employees must be paid 1.5 times their regular rate for hours over 44 in a work week. Many jobs are exempt or have special rules.",details:[{label:"Threshold",value:"44 hours in a work week"},{label:"Rate",value:"1.5 times the regular rate"}]},"on-public-holidays":{id:"on-public-holidays",title:"Ontario has nine public holidays",authority:"Province",jurisdiction:"CA-ON",reference:"ESA Part X",status:"in_force",url:"https://www.ontario.ca/document/your-guide-employment-standards-act-0/public-holidays",snippet:"Ontario has nine public holidays. Most employees get the day off with public holiday pay, or agree in writing to work it and get premium pay or a substitute day.",details:[{label:"Holidays",value:"Nine a year"},{label:"Working the day",value:"Premium pay or a substitute day"}]},"on-minimum-wage":{id:"on-minimum-wage",title:"Ontario minimum wage: $17.95 from October 1, 2026",authority:"Province",jurisdiction:"CA-ON",reference:"ESA ss.23, 23.1",effectiveDate:"2026-10-01",status:"in_force",url:"https://www.ontario.ca/document/your-guide-employment-standards-act-0/minimum-wage",snippet:"The general minimum wage is $17.60 an hour until September 30, 2026 and $17.95 from October 1, 2026. It is indexed to inflation and changes each October 1.",details:[{label:"Until Sept 30, 2026",value:"$17.60 an hour"},{label:"From Oct 1, 2026",value:"$17.95 an hour"}]},"on-electronic-monitoring":{id:"on-electronic-monitoring",title:"Written electronic monitoring policy from 25 employees",authority:"Province",jurisdiction:"CA-ON",reference:"ESA s.41.1.1",effectiveDate:"2022-04-11",status:"in_force",url:"https://www.ontario.ca/document/your-guide-employment-standards-act-0/written-policy-electronic-monitoring-employees",snippet:"Employers with 25 or more employees on January 1 need a written electronic monitoring policy in place before March 1, must give employees a copy, and keep old versions for three years.",details:[{label:"Applies to",value:"25 or more employees on January 1"},{label:"Keep",value:"Old versions for 3 years"}]},"on-record-keeping":{id:"on-record-keeping",title:"Ontario: keep employment records for three years",authority:"Province",jurisdiction:"CA-ON",reference:"ESA s.15",status:"in_force",url:"https://www.ontario.ca/document/your-guide-employment-standards-act-0/record-keeping",snippet:"Employers record each employee's name, address, start date, hours and pay, and generally keep those records three years. Job postings and application forms are also kept three years.",details:[{label:"Employee records",value:"3 years after the employee leaves"},{label:"Job postings",value:"3 years after the posting ends"}]},"on-esa-poster":{id:"on-esa-poster",title:"Give each new employee the ESA poster within 30 days",authority:"Province",jurisdiction:"CA-ON",reference:"ESA s.2; O. Reg. 285/01",status:"in_force",url:"https://www.ontario.ca/document/your-guide-employment-standards-act-0/mandatory-information-employees",snippet:"Give every new employee the Ministry's Employment Standards poster within 30 days of starting. Employers with 25 or more employees also give job basics in writing before the first day.",details:[{label:"Poster",value:"Within 30 days, once"},{label:"Written job basics",value:"25 or more employees, since July 1, 2025"}]},"on-reprisals":{id:"on-reprisals",title:"Ontario: employers can't punish employees for using ESA rights",authority:"Province",jurisdiction:"CA-ON",reference:"ESA s.74",status:"in_force",url:"https://www.ontario.ca/document/your-guide-employment-standards-act-0/reprisals",snippet:"Employers can't penalize or threaten employees for asking the employer to follow the ESA or for using their ESA rights, so a confidentiality clause can't be used to silence an ESA complaint.",details:[{label:"Not allowed",value:"Firing, cutting pay, suspending or threatening"},{label:"Applies to",value:"Employees covered by the ESA"}]},"on-esa-recent-changes":{id:"on-esa-recent-changes",title:"Ontario ESA: recent changes (a page to watch)",authority:"Province",jurisdiction:"CA-ON",reference:"ESA; O. Reg. 476/24",status:"in_force",url:"https://www.ontario.ca/document/your-guide-employment-standards-act-0/recent-changes",snippet:"Ontario's running list of Employment Standards Act changes, including the job posting rules in force since January 1, 2026 and other new requirements.",details:[{label:"Use",value:"Watch this page for new employer duties"}]},"on-bill-105-uniforms":{id:"on-bill-105-uniforms",title:"Proposed: Ontario would ban charging employees for uniforms",authority:"Province",jurisdiction:"CA-ON",reference:"Bill 105, proposed ESA s.13.1",effectiveDate:"2027-01-01",status:"proposed",url:"https://www.ola.org/en/legislative-business/bills/parliament-44/session-1/bill-105",snippet:"Bill 105 would bar employers from making employees pay for uniforms or their upkeep, with exceptions for loss and damage. It is not law yet.",details:[{label:"Status",value:"Bill, not yet law"},{label:"Would start",value:"January 1, 2027"}]},"on-ohsa-policies":{id:"on-ohsa-policies",title:"Every Ontario employer needs violence and harassment policies",authority:"Province",jurisdiction:"CA-ON",reference:"OHSA ss.32.0.1, 32.0.6",status:"in_force",url:"https://www.ontario.ca/page/understand-law-workplace-violence-and-harassment",snippet:"Every employer needs workplace violence and harassment policies, reviewed at least once a year. With six or more regularly employed workers they must be in writing and posted.",details:[{label:"Applies to",value:"Every employer, whatever its size"},{label:"Review",value:"At least once a year"}]},"wsib-registration":{id:"wsib-registration",title:"WSIB: register within 10 days of hiring your first employee",authority:"Province",jurisdiction:"CA-ON",reference:"Workplace Safety and Insurance Act, 1997",status:"in_force",url:"https://www.wsib.ca/en/howtoregister",snippet:"Most Ontario businesses with employees register with the WSIB within 10 calendar days of the first employee starting. Independent operators outside construction don't need to register.",details:[{label:"Deadline",value:"10 calendar days after the first employee starts"},{label:"Independent operators",value:"Not required, outside construction"}]},"wsib-independent-operators":{id:"wsib-independent-operators",title:"WSIB: an independent operator isn't automatically covered",authority:"Province",jurisdiction:"CA-ON",reference:"Workplace Safety and Insurance Act, 1997",status:"in_force",url:"https://www.wsib.ca/en/businesses/registration-and-coverage/independent-operators",snippet:"The WSIB decides whether a person is a worker or an independent operator. If a worker, the business reports and pays premiums, possibly back to the start; if an independent operator, it doesn't.",details:[{label:"Worker",value:"Business reports and pays premiums"},{label:"Independent operator",value:"No premiums; optional cover"}]},"ohrc-job-ads":{id:"ohrc-job-ads",title:"Human rights: job ads can't point to a protected ground",authority:"Province",jurisdiction:"CA-ON",reference:"Human Rights Code s.23(1)",status:"in_force",url:"https://www.ohrc.on.ca/en/iv-human-rights-issues-all-stages-employment/3-advertising",snippet:"A job ad can't say or hint at qualifications tied to a protected ground such as race, sex, age, disability or record of offences. Best practice is to advertise widely and say accommodation is available.",details:[{label:"Rule",value:"Human Rights Code s.23(1)"},{label:"Best practice",value:"Say accommodation is available"}]},"ohrc-applications-interviews":{id:"ohrc-applications-interviews",title:"Human rights: application forms and interviews",authority:"Province",jurisdiction:"CA-ON",reference:"Human Rights Code s.23(2), (3)",status:"in_force",url:"https://www.ohrc.on.ca/en/iv-human-rights-issues-all-stages-employment/4-designing-application-forms",snippet:"Application forms and written or oral questions can't ask about protected grounds such as age, sex, family status, disability or record of offences unless a Code exception applies.",details:[{label:"Age",value:"Ask only whether the applicant is 18 or over"},{label:"Interviews",value:"Ask everyone the same job-related questions"}]},"ohrc-criminal-records":{id:"ohrc-criminal-records",title:"Human rights: asking about criminal records when hiring",authority:"Province",jurisdiction:"CA-ON",reference:"Human Rights Code ss.5(1), 24(1)(b)",status:"in_force",url:"https://www.ohrc.on.ca/en/iv-human-rights-issues-all-stages-employment/5-interviewing-and-making-hiring-decisions",snippet:"Employers may ask about and consider unpardoned Criminal Code convictions. It is discriminatory to consider pardoned convictions or provincial offences unless a genuine job requirement applies.",details:[{label:"Allowed",value:"Unpardoned Criminal Code convictions"},{label:"Protected",value:"Pardoned convictions and provincial offences"}]},"ohrc-canadian-experience":{id:"ohrc-canadian-experience",title:"Human rights: a strict Canadian experience rule is discrimination",authority:"Province",jurisdiction:"CA-ON",reference:"Human Rights Code ss.5, 23",effectiveDate:"2013-02-01",status:"in_force",url:"https://www.ohrc.on.ca/en/policy-removing-canadian-experience-barrier",snippet:"The Human Rights Commission treats a strict requirement for Canadian experience as discrimination on its face, allowed only in very limited cases. The job posting rules in the ESA add their own ban.",details:[{label:"Policy approved",value:"February 1, 2013"},{label:"Onus",value:"On the employer to justify it"}]},"on-aoda-recruitment":{id:"on-aoda-recruitment",title:"Accessible hiring: tell applicants accommodation is available",authority:"Province",jurisdiction:"CA-ON",reference:"AODA, O. Reg. 191/11 ss.22-24",effectiveDate:"2017-01-01",status:"in_force",url:"https://www.ontario.ca/page/accessible-workplaces",snippet:"Tell employees and the public that accommodation is available in your hiring, for example in job postings, tell applicants chosen for assessment, and tell successful applicants about accommodation policies.",details:[{label:"Small organizations",value:"Since January 1, 2017"},{label:"How",value:"On your website or in job postings"}]},"on-police-record-checks":{id:"on-police-record-checks",title:"Ontario police record checks: three types, with consent",authority:"Province",jurisdiction:"CA-ON",reference:"Police Record Checks Reform Act, 2015",status:"in_force",url:"https://www.ontario.ca/page/police-record-checks",snippet:"There are three police record checks: criminal record, criminal record and judicial matters, and vulnerable sector. A check needs the person's written consent to that type of check.",details:[{label:"Consent",value:"Written, for the type of check"},{label:"Vulnerable sector",value:"Only for roles of trust over vulnerable people"}]},"cra-payroll-account":{id:"cra-payroll-account",title:"CRA: register a payroll account before your first remittance",authority:"CRA",jurisdiction:"CA",reference:"CRA payroll (RP) program account",status:"in_force",url:"https://www.canada.ca/en/revenue-agency/services/tax/businesses/topics/payroll/open-manage-payroll-account/determine-need-register.html",snippet:"An employer must register for a CRA payroll account before the first remittance is due. The payroll account attaches to the business number.",details:[{label:"Deadline",value:"Before the first remittance due date"}]},"cra-t4-due":{id:"cra-t4-due",title:"CRA: T4 and T4A slips are due the last day of February",authority:"CRA",jurisdiction:"CA",reference:"T4, T4A and T4 Summary",status:"in_force",url:"https://www.canada.ca/en/revenue-agency/services/tax/businesses/topics/payroll/file-information-returns-slip-summaries/when-to-file.html",snippet:"T4 and T4A returns for a calendar year are due the last day of February of the next year. If that is a weekend or holiday, the next business day counts as on time.",details:[{label:"Due",value:"Last day of February"},{label:"Weekend or holiday",value:"Next business day"}]},"cra-cpp-rates":{id:"cra-cpp-rates",title:"CRA: CPP for 2026, rate and earnings limits",authority:"CRA",jurisdiction:"CA",reference:"CPP contribution rates",effectiveDate:"2026-01-01",status:"in_force",url:"https://www.canada.ca/en/revenue-agency/services/tax/businesses/topics/payroll/payroll-deductions-contributions/canada-pension-plan-cpp/cpp-contribution-rates-maximums-exemptions.html",snippet:"For 2026, employees and employers each pay 5.95% of pensionable earnings above $3,500, up to $74,600. A second CPP rate applies to earnings above that limit.",details:[{label:"Rate",value:"5.95% each"},{label:"Basic exemption",value:"$3,500"},{label:"Earnings limit",value:"$74,600"}]},"cra-ei-premiums":{id:"cra-ei-premiums",title:"CRA: EI for 2026, premium rate and earnings limit",authority:"CRA",jurisdiction:"CA",reference:"EI premium rates",effectiveDate:"2026-01-01",status:"in_force",url:"https://www.canada.ca/en/revenue-agency/services/tax/businesses/topics/payroll/payroll-deductions-contributions/employment-insurance-ei/ei-premium-rates-maximums.html",snippet:"For 2026, employees pay 1.63% of insurable earnings up to $68,900. The employer pays 1.4 times the employee premium.",details:[{label:"Employee rate",value:"1.63%"},{label:"Earnings limit",value:"$68,900"},{label:"Employer",value:"1.4 times the employee premium"}]},"cra-t2-due":{id:"cra-t2-due",title:"CRA: file the T2 return within six months after the tax year ends",authority:"CRA",jurisdiction:"CA",reference:"When to file your corporation income tax return",status:"in_force",url:"https://www.canada.ca/en/revenue-agency/services/tax/businesses/topics/corporations/corporation-income-tax-return/when-file-your-corporation-income-tax-return.html",snippet:"A corporation files its T2 return no later than six months after the end of each tax year. If the due date is a Saturday, Sunday or CRA-recognized public holiday, the return is on time on the next business day.",details:[{label:"Due",value:"Six months after the tax year ends"},{label:"Weekend or holiday",value:"Next business day"}]},"cra-t2-balance-due":{id:"cra-t2-balance-due",title:"CRA: corporation tax owing is due two or three months after the year ends",authority:"CRA",jurisdiction:"CA",reference:"Balance-due day",status:"in_force",url:"https://www.canada.ca/en/revenue-agency/services/tax/businesses/topics/corporations/corporation-payments/paying-your-balance-corporation-tax/balance-day.html",snippet:"Any balance of corporation tax owing is due two months after the tax year ends, or three months for a Canadian-controlled private corporation that meets the small-business conditions.",details:[{label:"Most corporations",value:"Two months after the tax year ends"},{label:"Qualifying CCPC",value:"Three months after the tax year ends"}]},"cra-gst-hst-due":{id:"cra-gst-hst-due",title:"CRA: when GST/HST returns and payments are due",authority:"CRA",jurisdiction:"CA",reference:"GST/HST reporting requirements and deadlines",status:"in_force",url:"https://www.canada.ca/en/revenue-agency/services/tax/businesses/topics/gst-hst-businesses/file-gst-hst-return/reporting-requirements-deadlines.html",snippet:"Monthly and quarterly filers file and pay one month after the reporting period ends. Annual filers (other than individuals with business income) file and pay three months after their fiscal year ends.",details:[{label:"Monthly or quarterly",value:"One month after the period ends"},{label:"Annual",value:"Three months after the fiscal year ends"}]},"cra-gst-hst-netfile":{id:"cra-gst-hst-netfile",title:"CRA: how to file a GST/HST return online",authority:"CRA",jurisdiction:"CA",reference:"GST/HST NETFILE",status:"in_force",url:`${SB}/tax/businesses/topics/gst-hst-businesses/file-gst-hst-return/how-file.html`,snippet:"File in your CRA account (My Business Account or Represent a Client) with its built-in GST/HST NETFILE service, or use the NETFILE form with a 4-digit access code. Periods starting in 2024 or later must be filed electronically.",details:[{label:"In your CRA account",value:"My Business Account or Represent a Client, using NETFILE"},{label:"Access code",value:"4 digits, needed for the NETFILE form, third-party software or TELEFILE"},{label:"Must file electronically",value:"Reporting periods that begin in 2024 or later, except charities and selected listed financial institutions"},{label:"Not filing electronically",value:"The CRA charges a penalty"}]},"cra-gst-hst-file-in-account":{id:"cra-gst-hst-file-in-account",title:"CRA: file a GST/HST return in your CRA account",authority:"CRA",jurisdiction:"CA",reference:"GST/HST NETFILE in your CRA account",status:"in_force",url:`${SB}/tax/businesses/topics/gst-hst-businesses/file-gst-hst-return/how-file/in-your-cra-account.html`,snippet:"Sign in to your CRA account, choose your business or representative account, pick GST/HST and your RT number, then File a return. No access code is needed. A 6-digit confirmation number means the return was accepted.",details:[{label:"Have ready",value:"Your business number and the reporting period's from and to dates"},{label:"Access code",value:"Not needed in your CRA account"},{label:"Confirmation",value:"A 6-digit number after you submit"}]},"cra-gst-hst-return-lines":{id:"cra-gst-hst-return-lines",title:"CRA: what goes on each line of the GST/HST return",authority:"CRA",jurisdiction:"CA",reference:"GST/HST return lines 101 to 115",status:"in_force",url:`${SB}/tax/businesses/topics/gst-hst-businesses/calculate-prepare-report/instructions-preparing-return.html`,snippet:"Line 101 is total sales and other revenue, without GST/HST or PST. Line 103 is the GST/HST you collected or had to collect, and line 106 the input tax credits you claim. Line 109, net tax, is line 105 minus line 108.",details:[{label:"Line 101",value:"Revenue from supplies, including zero-rated and exempt ones; leave out PST, GST and HST"},{label:"Line 103",value:"GST/HST collected or collectible"},{label:"Line 106",value:"Eligible input tax credits"},{label:"Line 109",value:"Net tax: line 105 minus line 108"},{label:"Lines 114 and 115",value:"A refund, or the amount owing"}]},"cra-gst-hst-pay":{id:"cra-gst-hst-pay",title:"CRA: paying the GST/HST you collected",authority:"CRA",jurisdiction:"CA",reference:"Remit (pay) the GST/HST",status:"in_force",url:`${SB}/tax/businesses/topics/gst-hst-businesses/remit-pay-gst-hst-collected.html`,snippet:"Most GST/HST payments are due at the same time as the return. You can pay online, in person at a Canadian financial institution or Canada Post, or by mail. Paying online needs no remittance voucher.",details:[{label:"Due",value:"With the return, for most filers"},{label:"Different date",value:"Annual filers with a December 31 year-end and business income for tax purposes, or who pay by instalments"},{label:"Online",value:"No remittance voucher needed"},{label:"In person or by mail",value:"Needs a remittance voucher"}]},"cra-deposits-gst-hst":{id:"cra-deposits-gst-hst",title:"GST/HST on deposits: not payment until applied",authority:"CRA",jurisdiction:"CA",reference:"ETA 168(9) and 182; GST Memorandum 300-6-8",status:"in_force",url:`${SB}/forms-publications/publications/g300-6-8/deposits-gst-300-6-8.html`,snippet:"A deposit isn't treated as payment for a supply until the supplier applies it to the price. A refundable deposit that is refunded has no tax consequences. A forfeited deposit is treated as a taxable supply when it is forfeited.",details:[{label:"Deposit held",value:"Not consideration until applied to the price"},{label:"Refunded",value:"No GST/HST consequences"},{label:"Forfeited",value:"A taxable supply at the time of forfeiture (ETA 182)"},{label:"Age",value:"Issued in 1991 at the 7% GST rate; the CRA says it hasn't been updated for later changes"}]},"cra-t2-filing-methods":{id:"cra-t2-filing-methods",title:"CRA: file the T2 online with certified software",authority:"CRA",jurisdiction:"CA",reference:"Corporation Internet Filing",status:"in_force",url:`${SB}/e-services/digital-services-businesses/corporation-internet-filing/about-corporation-internet-filing-service.html`,snippet:"For tax years starting after 2023, all corporations must file the T2 electronically, with a few exceptions such as insurers and non-resident corporations. Corporation Internet Filing is free but needs CRA-certified software.",details:[{label:"Must file electronically",value:"Tax years starting after 2023"},{label:"Exceptions",value:"Insurance corporations, non-resident corporations, corporations reporting in a functional currency and corporations exempt under ITA 149"},{label:"Software",value:"CRA-certified; you may have to buy it"},{label:"Service",value:"Free of charge"}]},"cra-t2-pay":{id:"cra-t2-pay",title:"CRA: how to pay corporation income tax",authority:"CRA",jurisdiction:"CA",reference:"Corporate income tax payments",status:"in_force",url:`${SB}/tax/businesses/topics/corporations/corporation-payments/paying-instalments/how-pay.html`,snippet:"Payments must reach the CRA by the due date, or penalties and interest may apply. You can schedule pre-authorized debits in My Business Account or Represent a Client, and check payments and balances in My Business Account.",details:[{label:"Due",value:"Received by the CRA on or before the due date"},{label:"Scheduled payments",value:"Pre-authorized debit in My Business Account or Represent a Client, set up at least 5 business days ahead"},{label:"In person or by mail",value:"Needs a remittance voucher, such as RC158 when paying with the return"},{label:"Check",value:"Payments received and balances owing, in My Business Account"}]},"cra-schedule-50":{id:"cra-schedule-50",title:"T2 Schedule 50: shareholders with 10% or more",authority:"CRA",jurisdiction:"CA",reference:"T2 Schedule 50; Guide T4012, Chapter 2",status:"in_force",url:`${SB}/forms-publications/publications/t4012/t2-corporation-income-tax-guide-chapter-2-page-2-t2-return.html`,snippet:"A private corporation completes Schedule 50 when any shareholder holds 10% or more of its common or preferred shares. It lists at most the 10 top shareholders, with the information the schedule asks for.",details:[{label:"Who files it",value:"Private corporations"},{label:"Who is listed",value:"Shareholders with 10% or more of the common or preferred shares"},{label:"How many",value:"At most the 10 top shareholders"}]},"cra-ccpc":{id:"cra-ccpc",title:"What a Canadian-controlled private corporation (CCPC) is",authority:"CRA",jurisdiction:"CA",reference:"Guide T4012, Chapter 1",status:"in_force",url:`${SB}/forms-publications/publications/t4012/t2-corporation-income-tax-guide-chapter-1-page-1-t2-return.html`,snippet:"A CCPC is a private corporation resident in Canada at the end of its tax year that isn't controlled by non-residents or public corporations, and has no class of its shares listed on a designated stock exchange.",details:[{label:"Private",value:"It is a private corporation"},{label:"Residence",value:"Resident in Canada, and incorporated here or resident here since June 18, 1971"},{label:"Control",value:"Not controlled by non-residents, public corporations or a mix of them"},{label:"Shares",value:"No class listed on a designated stock exchange"},{label:"Tested",value:"At the end of the tax year"}]},"cra-income-received-in-advance":{id:"cra-income-received-in-advance",title:"Income Tax Act: a reserve for goods and services not yet provided",authority:"Justice Canada",jurisdiction:"CA",reference:"ITA 12(1)(a) and 20(1)(m)",status:"in_force",url:"https://laws-lois.justice.gc.ca/eng/acts/I-3.3/section-20.html",snippet:"When amounts described in ITA 12(1)(a) are included in business income, a business may deduct a reasonable reserve for goods it expects to deliver, or services it expects to render, after the end of the year.",details:[{label:"Applies when",value:"Amounts described in 12(1)(a) were included in business income"},{label:"Reserve for",value:"Goods to be delivered or services to be rendered after the year ends"},{label:"Amount",value:"A reasonable amount"}]},"cra-t5-dividends":{id:"cra-t5-dividends",title:"CRA: T5 slips for dividends and other investment income",authority:"CRA",jurisdiction:"CA",reference:"Guide T4015, T5 Guide",status:"in_force",url:`${SB}/forms-publications/publications/t4015/t5-guide-return-investment-income.html`,snippet:"Whoever pays certain investment income, such as dividends, to a resident of Canada files a T5 return and gives slips by the last day of February. No slip is needed when one recipient's total for the year is under $50.",details:[{label:"Due",value:"Last day of February after the calendar year, for the return and the slips"},{label:"Under $50",value:"No slip for one recipient whose total for the year is less than $50"},{label:"File electronically",value:"More than 5 slips for a calendar year"},{label:"Dividends",value:"Eligible and other than eligible dividends go in separate boxes"}]},"cra-owner-manager-pay":{id:"cra-owner-manager-pay",title:"CRA: dividends are a return on investment, not pay for work",authority:"CRA",jurisdiction:"CA",reference:"Shareholder benefits",status:"in_force",url:`${SB}/tax/businesses/topics/payroll/calculating-deductions/determining-tax-treatment/shareholder.html`,snippet:"Dividends are a return on the shareholder's investment, not payment for services to the corporation. A shareholder may also be employed by the corporation. Benefits received as a shareholder are reported on a T4A.",details:[{label:"Dividends",value:"A return on investment, not pay for services"},{label:"Working shareholder",value:"May also be an employee of the corporation"},{label:"Shareholder benefits",value:"No income tax, CPP or EI withheld; T4A code 028 or 117 when over $500 a year"}]},"corporations-canada-annual-return":{id:"corporations-canada-annual-return",title:"Corporations Canada: the annual return is due within 60 days of the anniversary",authority:"Government of Canada",jurisdiction:"CA",reference:"Canada Business Corporations Act",status:"in_force",url:"https://ised-isde.canada.ca/site/corporations-canada/en/annual-return-business-corporations",snippet:"Every federal business corporation files an annual return with Corporations Canada each year, with its individuals with significant control, within 60 days after its anniversary date. Filing online costs $12.",details:[{label:"Due",value:"Within 60 days after the incorporation, amalgamation or continuance anniversary"},{label:"Also file",value:"Information on individuals with significant control, at the same time"},{label:"Fee",value:"$12 online"},{label:"Not filing",value:"The corporation may be dissolved"},{label:"Tax return",value:"A separate filing from the annual return"}]},"ontario-annual-return":{id:"ontario-annual-return",title:"Ontario: file the annual return in the Ontario Business Registry",authority:"Province",jurisdiction:"CA-ON",reference:"Corporations Information Act",status:"in_force",url:"https://www.ontario.ca/page/ontario-business-registry",snippet:"Corporations must file an annual return through the Ontario Business Registry each year within 6 months of their fiscal year-end. Filing online needs a company key, a 9-digit code unique to the business.",details:[{label:"Due",value:"Within 6 months of the fiscal year-end"},{label:"Where",value:"Ontario Business Registry"},{label:"You need",value:"A company key, an Ontario.ca Login and an Ontario Business Account"},{label:"Company key",value:"Free from the ministry by email or mail; keep it private"}]},"cra-remittance-due":{id:"cra-remittance-due",title:"CRA: regular remitters pay payroll deductions by the 15th",authority:"CRA",jurisdiction:"CA",reference:"CRA payroll remittances",status:"in_force",url:"https://www.canada.ca/en/revenue-agency/services/tax/businesses/topics/payroll/remitting-source-deductions/how-when-remit-due-dates.html",snippet:"Regular remitters pay payroll deductions by the 15th day of the next month. Quarterly and accelerated remitters have different due dates listed on the same page.",details:[{label:"Regular remitter",value:"15th of the next month"}]},"cra-records-six-years":{id:"cra-records-six-years",title:"CRA: keep business records for six years",authority:"CRA",jurisdiction:"CA",reference:"CRA record keeping",status:"in_force",url:"https://www.canada.ca/en/revenue-agency/services/tax/businesses/topics/keeping-records/where-keep-your-records-long-request-permission-destroy-them-early.html",snippet:"Generally, keep required records and supporting documents for six years from the end of the last tax year they relate to. Destroying them earlier needs CRA permission.",details:[{label:"Keep",value:"6 years from the end of the last tax year"}]},"cra-employer-sin":{id:"cra-employer-sin",title:"CRA: get a new employee's SIN within three days",authority:"CRA",jurisdiction:"CA",reference:"Employment Insurance Act",status:"in_force",url:"https://www.canada.ca/en/revenue-agency/services/tax/businesses/topics/payroll/set-up-new-employee/social-insurance-number.html",snippet:"Get the SIN from a new employee within 3 days of their start. A SIN beginning with 9 belongs to a temporary worker and is valid only until the work permit expires.",details:[{label:"Deadline",value:"Within 3 days of starting work"},{label:"SIN starting with 9",value:"Valid until the permit expires"}]},"cra-employment-status":{id:"cra-employment-status",title:"CRA: employee or self-employed, the two-step test",authority:"CRA",jurisdiction:"CA",reference:"CRA employment status (replaces RC4110)",status:"in_force",url:"https://www.canada.ca/en/revenue-agency/services/tax/canada-pension-plan-cpp-employment-insurance-ei-rulings/employee-self-employed/contract-outside-quebec.html",snippet:"Outside Quebec, the CRA first looks at what the worker and payer intended, then at the facts: control, tools, chance of profit or risk of loss, and how connected the work is to the business.",details:[{label:"Step 1",value:"What both sides intended"},{label:"Step 2",value:"Control, tools, profit or loss, integration"}]},"clc-dependent-contractor":{id:"clc-dependent-contractor",title:"Canada Labour Code: a dependent contractor counts as an employee",authority:"Justice Canada",jurisdiction:"CA",reference:"Canada Labour Code s.3(1)",status:"in_force",url:"https://laws-lois.justice.gc.ca/eng/acts/L-2/section-3.html",snippet:"For federally regulated employers only, the Canada Labour Code counts a person in a position of economic dependence as an employee. It doesn't apply to most Ontario companies.",details:[{label:"Applies to",value:"Federally regulated employers only"},{label:"Test",value:"Economic dependence"}]},"copyright-act-13":{id:"copyright-act-13",title:"Copyright: a contractor's work needs a signed written transfer",authority:"Justice Canada",jurisdiction:"CA",reference:"Copyright Act s.13",status:"in_force",url:"https://laws-lois.justice.gc.ca/eng/acts/C-42/section-13.html",snippet:"The author first owns a work. An employer first owns work made in the course of employment unless agreed otherwise. A transfer of copyright is valid only in writing signed by the owner.",details:[{label:"Employee work",value:"Employer owns, unless agreed otherwise"},{label:"Contractor work",value:"Needs a signed written assignment"}]},"cipo-ndas":{id:"cipo-ndas",title:"CIPO: have employees and contractors sign NDAs for trade secrets",authority:"Government of Canada",jurisdiction:"CA",reference:"CIPO, Plan your IP strategy",status:"in_force",url:"https://ised-isde.canada.ca/site/canadian-intellectual-property-office/en/plan-your-ip-strategy-html-version",snippet:"To keep trade secrets protected, have employees, contractors and business partners sign nondisclosure agreements. Trade secrets can't be registered, so confidentiality is the protection.",details:[{label:"Trade secrets",value:"Can't be registered"},{label:"Protection",value:"Nondisclosure agreements"}]},"criminal-code-425-1":{id:"criminal-code-425-1",title:"Criminal Code: no retaliating against employees who talk to police",authority:"Justice Canada",jurisdiction:"CA",reference:"Criminal Code s.425.1",status:"in_force",url:"https://laws-lois.justice.gc.ca/eng/acts/C-46/section-425.1.html",snippet:"An employer can't discipline, demote, fire or threaten an employee to stop them giving information to law enforcement about an offence, or for having done so. That limits what an NDA can do.",details:[{label:"Breach",value:"A criminal offence"}]},"opc-pipeda-scope":{id:"opc-pipeda-scope",title:"PIPEDA covers private-sector commercial activity",authority:"Government of Canada",jurisdiction:"CA",reference:"PIPEDA",status:"in_force",url:"https://www.priv.gc.ca/en/privacy-topics/privacy-laws-in-canada/the-personal-information-protection-and-electronic-documents-act-pipeda/pipeda_brief/",snippet:"PIPEDA applies to private-sector organizations that collect, use or disclose personal information in the course of commercial activity. Provinces with their own similar laws are generally exempt in-province.",details:[{label:"Applies to",value:"Commercial activity"},{label:"Own similar laws",value:"Alberta, British Columbia, Quebec"}]},"opc-employee-records":{id:"opc-employee-records",title:"PIPEDA covers employee records only at federal businesses",authority:"Government of Canada",jurisdiction:"CA",reference:"PIPEDA",status:"in_force",url:"https://www.priv.gc.ca/en/privacy-topics/employers-and-employees/02_05_d_18/",snippet:"The Privacy Commissioner says PIPEDA covers employee information only in federally regulated businesses. A provincially regulated employer, such as most Ontario companies, isn't covered for employee records.",details:[{label:"Federal businesses",value:"Telecom, banking, interprovincial transport"},{label:"Job applicants",value:"Not addressed on this page"}]},"opc-ten-principles":{id:"opc-ten-principles",title:"PIPEDA's ten fair information principles",authority:"Government of Canada",jurisdiction:"CA",reference:"PIPEDA Schedule 1",status:"in_force",url:"https://www.priv.gc.ca/en/privacy-topics/privacy-laws-in-canada/the-personal-information-protection-and-electronic-documents-act-pipeda/p_principle/",snippet:"The ten principles are the ground rules for collecting, using and disclosing personal information in commercial activity, from accountability and consent to safeguards and access.",details:[{label:"Includes",value:"Consent, limiting collection, safeguards, access"}]},"ircc-work-permit-duties":{id:"ircc-work-permit-duties",title:"Hiring someone with a work permit: see it and note its expiry",authority:"Government of Canada",jurisdiction:"CA",reference:"IRPR employer compliance",status:"in_force",url:"https://www.canada.ca/en/immigration-refugees-citizenship/services/work-canada/hire-temporary-foreign/international-mobility-program/after-hiring.html",snippet:"When hiring under the International Mobility Program, see the worker's permit, know its expiry date, and make sure the job meets the permit's conditions. Keep employment documents for six years.",details:[{label:"Check",value:"The permit and its expiry date"},{label:"Keep",value:"Employment documents for 6 years"}]},"bc-pay-transparency":{id:"bc-pay-transparency",title:"BC: public job postings must show the pay",authority:"Province",jurisdiction:"CA-BC",reference:"Pay Transparency Act s.2",effectiveDate:"2023-11-01",status:"in_force",url:"https://www2.gov.bc.ca/gov/content/governments/about-the-bc-government/gender-equity/wage-or-salary-information-on-job-postings",snippet:"BC employers, except federally regulated ones, must include the expected pay or pay range in every publicly advertised job posting. There is no employee-size threshold for postings.",details:[{label:"In force",value:"Since November 1, 2023"},{label:"Applies to",value:"All BC employers with employees"}]},"bc-employment-standards":{id:"bc-employment-standards",title:"BC employment standards (a page to watch)",authority:"Province",jurisdiction:"CA-BC",reference:"Employment Standards Act, RSBC 1996 c.113",status:"in_force",url:"https://www2.gov.bc.ca/gov/content/employment-business/employment-standards-advice",snippet:"The BC Employment Standards Branch runs the Employment Standards Act, which sets basic pay and working conditions for BC employees. Watch this page for changes.",details:[{label:"Applies to",value:"BC employees"}]},"ab-employment-standards":{id:"ab-employment-standards",title:"Alberta employment standards (a page to watch)",authority:"Province",jurisdiction:"CA-AB",reference:"Employment Standards Code, RSA 2000 c.E-9",status:"in_force",url:"https://www.alberta.ca/employment-standards",snippet:"Alberta.ca's main page for employment standards rules and compliance for employers and employees in Alberta workplaces. Watch this page for changes.",details:[{label:"Applies to",value:"Alberta employees"}]}}});function Vu(A){return G2.find((Q)=>Q.id===A)??G2[G2.length-1]}var G2,OmQ;var _u=W(()=>{HNA();G2=[{id:"hiring",label:"Hiring and job postings",description:"Pay ranges, job ads, interviews and work permits",icon:"briefcase",questions:["What must an Ontario job posting include?","Do we have to say if we use AI to screen applicants?","What can we ask in an interview or on an application?","Can we run a background check on a candidate?","How do we check someone is allowed to work in Canada?"],factTopics:["hiring_job_postings","human_rights_hiring","background_checks","accessibility_hiring","pay_transparency","work_authorization","interviews"],keywords:["job posting*","job post","job ad*","pay range","pay transparency","applicant*","interview*","hire","hiring","recruit*","background check*","criminal record*","reference check*","canadian experience","work permit*","work authorization","authorized to work","allowed to work","ai screening","screen applicants","human rights","discriminat*","accommodat*","accessib*"]},{id:"contractors",label:"Contractors and classification",description:"Contractor or employee, misclassification, T4A",icon:"users",questions:["How do I tell if someone is a contractor or an employee?","What happens if we treat an employee as a contractor?","When do Canadian contractor payments need a T4A?","When does a U.S. payer need Form 1099-NEC?","Which W-9 or W-8 should a cross-border contractor give us?","What if a Canadian contractor performs services in Iraq or the United States?"],factTopics:["worker_classification","dependent_contractor","contractor_reporting","misclassification"],keywords:["contractor*","independent contractor*","dependent contractor*","misclassif*","employee or","self-employed","freelanc*","t4a","1099","w-9","w-8","non-resident","service location","services performed","cross-border","cross border"]},{id:"agreements",label:"NDAs and agreements",description:"Confidentiality, who owns the work, non-competes",icon:"file-signature",questions:["Can we make employees sign a non-compete in Ontario?","Who owns work a contractor creates for us?","What can an NDA cover, and what can't it stop?","What should a contractor agreement say about pay and ending the work?"],factTopics:["ndas","non_compete","contractor_agreements","ip_assignment","confidentiality"],keywords:["nda","ndas","non-disclosure","nondisclosure","confidential*","non-compete*","noncompete*","non compete*","non-solicit*","nonsolicit*","agreement*","contract","contracts","intellectual property","copyright","assign*","whistleblow*","trade secret*"]},{id:"employment",label:"Employment standards",description:"Vacation, termination, overtime, holidays, minimum wage",icon:"scale",questions:["How much vacation must an Ontario employee get?","How much notice or pay do we owe when employment ends?","When do employees get overtime pay?","What is the Ontario minimum wage?","What records must we keep, and for how long?"],factTopics:["employment_standards","record_retention","electronic_monitoring","workplace_safety","minimum_wage","termination","overtime","vacation"],keywords:["vacation","terminat*","severance","notice period","overtime","public holiday*","holiday pay","minimum wage","employment standards","hours of work","electronic monitoring","record keeping","records must","harassment","fired","lay off","layoff"]},{id:"payroll",label:"Payroll and tax slips",description:"CRA and IRS payroll accounts, employee slips and remittances",icon:"receipt",questions:["When do we need a CRA payroll account?","When are T4 and T4A slips due?","What are the CPP and EI rates this year?","Which U.S. payroll returns and deposits apply?","How long do we keep payroll records?","How do we file T4A slips ourselves?","Should an owner be paid a salary or dividends?"],factTopics:["payroll_basics","information_slips","cpp_ei","payroll_remittance","us_payroll","owner_pay"],keywords:["payroll","t4","t4a","t5","w-2","form 941","form 940","cpp","canada pension","ei premium*","employment insurance","remit*","source deductions","payroll account","rp account","record of employment","salary","dividend*","pay myself","pay ourselves","pay yourself","owner-manager*"]},{id:"privacy",label:"Privacy",description:"Applicant data, SINs and personal information",icon:"shield",questions:["When can we ask for someone's SIN?","Does privacy law cover job applicants' information?","How long can we keep applicant information?","What are the privacy principles for personal information?"],factTopics:["privacy_hr","sin","privacy"],keywords:["privacy","pipeda","personal information","sin","social insurance","applicant data","consent to collect","data breach"]},{id:"taxes",label:"Taxes and filings",description:"Canadian and U.S. business taxes, sales-tax registrations and filings",icon:"landmark",questions:["What is new for Canadian businesses?","What U.S. federal return does our company file?","Which state or provincial registrations should we review?","Which sales-tax accounts and filing dates are saved for the company?","Which meals and events can we deduct?","How do we file our own GST/HST return?","When is our corporate tax due?","When is the corporation's annual return due?"],factTopics:["us_corporate_filing","business_registration","state_sales_tax","corporate_filing","gst_hst","annual_returns","revenue_timing"],keywords:["tax","taxes","gst","hst","deduct*","gifi","t2","1120","1065","1120-s","irs","llc tax classification","state tax","provincial registration","foreign qualification","nexus","sales tax","sales-tax","use tax","cca","capital cost*","filing*","meals","itc","input tax credit*","netfile","annual return*","schedule 50","shareholder*","ccpc","refundable deposit*","commitment fee*","payment processor*","stripe","bank charges"]}],OmQ=G2.filter((A)=>A.id!=="taxes")});var Ou,XNA;var ZNA=W(()=>{CNA();KNA();_u();Ou={platform_change:"Change Oatmilk",setting_change:"Update a setting",rule_to_review:"Rule to review",library_change:"Suggested library change",library_check:"Library entry to check"},XNA={platform_change:"Review",setting_change:"Review",rule_to_review:"Review",library_change:"Review",library_check:"Check"}});function bD(A){let Q=(A??"").trim();if(Object.hasOwn(NNA,Q))return NNA[Q];let B=Q.replaceAll("_"," ").trim();return{label:B?B.charAt(0).toUpperCase()+B.slice(1):"Unknown",tone:"neutral",summary:B?`Current state: ${B}.`:"No status has been recorded yet."}}var NNA;var Lu=W(()=>{NNA={prepared:{label:"Uploading",tone:"active",summary:"The file is being uploaded. Processing starts as soon as the upload is confirmed."},queued:{label:"Queued",tone:"active",summary:"Waiting for its turn. Processing usually starts within a few seconds.",next:"Open live activity to watch it start."},processing:{label:"Processing",tone:"active",summary:"The original is saved and details are being read and checked right now.",next:"Open live activity to see each step as it happens."},running:{label:"Running",tone:"active",summary:"This automation is working right now.",next:"Open live activity to follow each step."},review:{label:"Ready for review",tone:"warning",summary:"Details were read automatically. A person should confirm them before they count as final.",next:"Open it to review the details."},needs_review:{label:"Needs review",tone:"warning",summary:"This record was created automatically or changed and hasn't been confirmed by a person yet.",next:"Review the details and mark it reviewed."},reviewed:{label:"Reviewed",tone:"success",summary:"A person confirmed these details."},auto_reviewed:{label:"Done by AI",tone:"success",summary:"Oatmilk verified this against its source records and finished it automatically. A person can still change it."},tax_to_confirm:{label:"Confirm tax",tone:"warning",summary:"The source didn't include verified sales tax, so the tax amount still needs confirming.",next:"Open it to confirm the tax from the invoice or receipt."},ai_working:{label:"AI working",tone:"active",summary:"Oatmilk is classifying this transaction and checking its evidence."},ai_waiting:{label:"Finding receipt",tone:"info",summary:"Oatmilk is still looking for the receipt and checks again daily before asking anyone."},needs_receipt:{label:"Needs receipt",tone:"warning",summary:"Oatmilk searched and couldn't find the receipt.",next:"Forward the receipt email to your Oatmilk address or upload it."},needs_invoice:{label:"Needs invoice",tone:"warning",summary:"A contractor payment without the contractor's invoice or agreement.",next:"Upload the contractor's invoice or forward it to your Oatmilk address."},needs_category:{label:"Choose category",tone:"warning",summary:"Oatmilk couldn't tell what this was for with enough confidence.",next:"Pick a category. Oatmilk remembers it for this merchant."},needs_business_check:{label:"Business or personal?",tone:"warning",summary:"This looks like it might be personal.",next:"Choose a category if it's a business cost."},needs_income_check:{label:"Confirm income",tone:"warning",summary:"Money came in that Oatmilk couldn't tie to an invoice.",next:"Link the invoice or confirm it's customer income."},needs_statement:{label:"Needs statement",tone:"warning",summary:"The receipt is on a card whose statement hasn't been imported for that date.",next:"Import the card statement so Oatmilk can match the receipt."},needs_payout_match:{label:"Match payout",tone:"warning",summary:"This Stripe payout hasn't been matched to the bank deposit that received it.",next:"Connect or import the account that received the payout."},ready_to_approve:{label:"Ready to approve",tone:"info",summary:"Oatmilk prepared everything; automatic completion is turned off.",next:"Approve it to finish."},completed:{label:"Done",tone:"success",summary:"Processing finished and the results are saved."},complete:{label:"Complete",tone:"success",summary:"Everything for this item is finished."},succeeded:{label:"Done",tone:"success",summary:"The run finished successfully."},quarantined:{label:"Held for safety",tone:"danger",summary:"This was held back because the sender, recipients, or content need an administrator's check. Originals are preserved.",next:"An administrator can review and release it."},failed:{label:"Needs attention",tone:"danger",summary:"Processing stopped before it finished. The original is still saved.",next:"Open it to see what happened and retry."},cancelled:{label:"Cancelled",tone:"neutral",summary:"This was cancelled and will not continue."},matched:{label:"Matched",tone:"success",summary:"Linked to its bank or payment record."},accountant_reports_draft:{label:"Draft",tone:"warning",summary:"Some records are still open, so the reports say they're a draft. They can still be sent to the accountant.",next:"Finish the open records in the tax checklist to update the numbers."},accountant_reports_ready:{label:"Up to date",tone:"success",summary:"Every record is reviewed and every account balance is known."},unmatched:{label:"Not matched",tone:"warning",summary:"No bank or payment record has been linked yet.",next:"Open reconciliation to find the matching transaction."},closed:{label:"Closed",tone:"success",summary:"This period's balances were confirmed and it is locked against changes."},open:{label:"Open",tone:"neutral",summary:"Records in this period can still change."},active:{label:"Active",tone:"success",summary:"Currently in use."},inactive:{label:"Inactive",tone:"neutral",summary:"Not currently in use."},deleted:{label:"Deleted",tone:"neutral",summary:"A person deleted this transaction. It no longer counts in any total; its files and history are kept.",next:"Open it to see who deleted it and why, or to restore it."},reversed:{label:"Reversed",tone:"neutral",summary:"This imported bank row was excluded from the books. Its original is preserved and it can be restored."},received:{label:"Received",tone:"active",summary:"The email arrived and is waiting to be processed."},ready:{label:"Ready",tone:"success",summary:"The email was processed and is ready to read."},promoted:{label:"Added to books",tone:"success",summary:"This email's financial details were added to accounting."},draft:{label:"Draft",tone:"neutral",summary:"Not sent or finalized yet. You can still edit it."},scheduled:{label:"Scheduled",tone:"info",summary:"Prepared and scheduled for a future date."},awaiting_approval:{label:"Awaiting approval",tone:"warning",summary:"Prepared ahead of its send date and waiting for an administrator to approve it.",next:"Review and approve it before the send date."},approved:{label:"Approved",tone:"success",summary:"Approved and ready to go out on its scheduled date."},sent:{label:"Sent",tone:"info",summary:"Delivered to the email provider for the recipients."},partially_paid:{label:"Partly paid",tone:"warning",summary:"Some of this invoice has been paid; a balance remains."},paid:{label:"Paid",tone:"success",summary:"Paid in full."},overdue:{label:"Overdue",tone:"danger",summary:"The due date has passed and a balance remains.",next:"Follow up or record the payment if it arrived."},void:{label:"Void",tone:"neutral",summary:"Cancelled. It remains on record but no longer counts."},uncollectible:{label:"Uncollectible",tone:"neutral",summary:"Marked as not collectible."},requested:{label:"Awaiting signature",tone:"warning",summary:"Sent for signature and waiting on the signer."},in_progress:{label:"In progress",tone:"info",summary:"Some signers have finished; others are still pending."},signed:{label:"Signed",tone:"success",summary:"Signed by the recipient."},declined:{label:"Declined",tone:"danger",summary:"A recipient declined to sign.",next:"Open it to read their reason and revise if needed."},expired:{label:"Expired",tone:"neutral",summary:"The signing window ended before everyone signed."},viewed:{label:"Viewed",tone:"info",summary:"The recipient opened the document."},pending:{label:"Pending",tone:"neutral",summary:"Waiting for an earlier step to finish."},submitted:{label:"Submitted",tone:"warning",summary:"Submitted and waiting for review.",next:"Review and approve or return it."},rejected:{label:"Returned",tone:"danger",summary:"Returned for correction with a note."},upcoming:{label:"Upcoming",tone:"info",summary:"Due in the future. Reminders go out as the date approaches."},done:{label:"Done",tone:"success",summary:"Marked complete."},skipped:{label:"Not applicable",tone:"neutral",summary:"Marked as not applicable for this period."},due_soon:{label:"Due soon",tone:"warning",summary:"Due within the next two weeks."},due_today:{label:"Due today",tone:"danger",summary:"Due today."},proposed:{label:"Suggested",tone:"warning",summary:"Suggested automatically and waiting for a person to confirm."},confirmed:{label:"Confirmed",tone:"success",summary:"Confirmed by a person."},applied:{label:"Applied",tone:"success",summary:"The approved change was applied."},superseded:{label:"Replaced",tone:"neutral",summary:"A newer suggestion replaced this one."},delivered:{label:"Delivered",tone:"success",summary:"Delivered successfully."},bounced:{label:"Bounced",tone:"danger",summary:"The recipient's mail server rejected the message."},connected:{label:"Connected",tone:"success",summary:"The connection is set up and working."},not_configured:{label:"Not set up",tone:"neutral",summary:"This connection hasn't been set up in this environment yet."},error:{label:"Error",tone:"danger",summary:"The last check failed. Open it to see why."},disabled:{label:"Off",tone:"neutral",summary:"Turned off."},onboarding:{label:"Onboarding",tone:"info",summary:"Profile or agreement steps are still in progress."},processing_payment:{label:"Paying",tone:"active",summary:"The payment is being created with the bank or payment provider."},pending_approval:{label:"Needs approval",tone:"warning",summary:"Waiting for an administrator to approve it."},needs_contractor:{label:"Choose contractor",tone:"warning",summary:"This outgoing payment may belong to a contractor. Choose who was paid or mark it unrelated."},payout_sent:{label:"Payment sent",tone:"success",summary:"Wise accepted and funded the transfer. Most payments arrive within 1–3 business days.",next:"Open live activity to see each payment step."},payout_failed:{label:"Payment needs attention",tone:"danger",summary:"The payment didn't finish. Nothing is sent twice; retrying reuses the same Wise transfer.",next:"Open it to see what happened and retry."},paid_manually:{label:"Paid outside Wise",tone:"success",summary:"Recorded as paid through another method, with a payment reference."},incomplete:{label:"Incomplete",tone:"warning",summary:"Some required details are still missing.",next:"Open it to see what's missing."},agreement_missing:{label:"No agreement",tone:"warning",summary:"No signed agreement is on file yet.",next:"Send one from a template or upload an agreement that's already signed."},on_file:{label:"On file",tone:"success",summary:"A signed agreement is on file."},terms_on_file:{label:"Terms on file",tone:"success",summary:"The agreement's terms are recorded as agreed. The signed copy is kept elsewhere; upload it to keep it here too."},signed_elsewhere:{label:"Signed elsewhere",tone:"success",summary:"The signed agreement is kept outside Oatmilk, at the link recorded with it.",next:"Upload the signed copy to keep it here too."},agreement_unsigned:{label:"Not signed",tone:"neutral",summary:"Imported as a draft. It isn't signed, so it doesn't count as the agreement on file."},agreement_ended:{label:"Agreement ended",tone:"warning",summary:"The agreement's end date passed and nobody has decided what happens next. Nothing is blocked.",next:"Renew it, keep them working without renewing, or let it end."},agreement_lapsed:{label:"Ended, still working",tone:"warning",summary:"The agreement ended and timesheets, pay periods or payments continued after its end date. Nothing is blocked.",next:"Renew it from the day after it ended, keep them working without renewing, or let it end."},agreement_queued:{label:"Waiting to be read",tone:"info",summary:"An update is out for signature, so this agreement's terms are read once it's signed or withdrawn."},agreement_history:{label:"Kept as history",tone:"neutral",summary:"It's older than the terms in effect, or doesn't say when it starts, so it doesn't replace them.",next:"Read its terms if it should replace the current ones."},agreement_unread:{label:"Couldn't read",tone:"warning",summary:"Oatmilk couldn't read this agreement's terms.",next:"Read its terms again, or enter them by hand."},invite_pending:{label:"Invite not accepted",tone:"warning",summary:"The contractor was invited to the portal and hasn't joined yet.",next:"Resend the invite, or copy their link and send it yourself."},invite_bounced:{label:"Invite bounced",tone:"danger",summary:"The invitation email couldn't be delivered, so the contractor can't join yet.",next:"Fix the email address or send them the link yourself."},invite_expired:{label:"Invite expired",tone:"warning",summary:"The invite ran out before the contractor joined.",next:"Send a new invite."},invite_requested:{label:"Wants a new invite",tone:"warning",summary:"The contractor asked for a new invitation to the portal.",next:"Send a new invite."},verified:{label:"Verified",tone:"success",summary:"An administrator confirmed these payment details directly with the contractor."},unverified:{label:"Not verified",tone:"neutral",summary:"These payment details haven't been confirmed directly with the contractor yet."},sales_tax_confirmed:{label:"Sales tax confirmed",tone:"success",summary:"Finance confirmed the GST/HST rate. Payouts add sales tax at this rate."},sales_tax_unconfirmed:{label:"Sales tax not confirmed",tone:"warning",summary:"The contractor says they charge GST/HST, but finance hasn't confirmed the rate. Payouts don't include it yet.",next:"Check their registration, then confirm or correct the rate."},sales_tax_changed:{label:"Sales tax changed",tone:"warning",summary:"The contractor changed their GST/HST answers after finance confirmed them. Payouts don't include it until it's confirmed again.",next:"Check the new answers, then confirm or correct the rate."},sales_tax_not_charged:{label:"No sales tax",tone:"neutral",summary:"The contractor says they don't charge GST/HST, so none is added to payouts."},late:{label:"Late",tone:"danger",summary:"The due date passed without submitted hours. Late reminders go out automatically."},voided:{label:"Voided",tone:"neutral",summary:"Cancelled by the sender. Signing links no longer work, and the record is kept."},completing:{label:"Finalizing",tone:"active",summary:"Everyone signed. The completed PDF with its certificate is being prepared and emailed.",next:"This usually takes a few seconds."},executed:{label:"Signed",tone:"success",summary:"Signed outside Oatmilk and saved as the agreement on file. The original file is kept unchanged."},paused:{label:"Paused",tone:"neutral",summary:"Paused. Nothing new is prepared or sent until it's resumed."},archived:{label:"Archived",tone:"neutral",summary:"Hidden from new work. Its history is kept."},delayed:{label:"Delayed",tone:"warning",summary:"The recipient's mail server is slow to accept the message. Delivery is retried automatically."},opened:{label:"Opened",tone:"success",summary:"The recipient opened the email."},clicked:{label:"Clicked",tone:"success",summary:"The recipient opened a link in the email."},complained:{label:"Marked as spam",tone:"danger",summary:"The recipient reported the email as spam. Check the address before sending again."},locked:{label:"Locked",tone:"danger",summary:"This signing link was locked after too many verification code attempts. The signer can't use it anymore.",next:"Open the document and send them a new link."},changes_requested:{label:"Changes requested",tone:"warning",summary:"A signer suggested changes. Nobody can sign until you answer them.",next:"Review the changes, then send a revised version or keep it as it is."}}});function WNA(A,Q,B){return{rows:A.slice(0,Q),total:B,hasMore:A.length>Q}}function g4(A,Q,B=0){let E=A,I=E.items??[];if("nextCursor"in(E??{}))return{rows:I,hasMore:!!E.nextCursor,nextCursor:E.nextCursor??null};return{rows:I,total:E.total,hasMore:typeof E.total==="number"?B+I.length<E.total&&I.length>=Q:I.length>=Q}}function ME(A,Q){let B=Math.min(16,Math.max(...A.map(([I])=>I.length))+2),E=[];for(let[I,D]of A){if(D===null||D===void 0||D==="")continue;let J=typeof D==="string"?{text:D}:D;E.push(...eQ([J],Q,[{text:I.padEnd(B),color:L.muted}]))}return E}function wB(A,Q){return[[],[{text:A,bold:!0}],[{text:"─".repeat(Math.max(4,Math.min(Q,A.length+2))),color:L.border}]]}function R4(A,Q,B={}){return typeof A==="string"&&A.trim()?eQ([{text:A.trim(),...B}],Q):[]}function jNA(A){return dBQ[A.split(".").pop()?.toLowerCase()??""]??null}async function gu(A,Q,B){let E=await A.prompt({title:Q,label:"Path to the file (PDF, photo or .eml, up to 2 MB)",placeholder:"~/Downloads/receipt.pdf"});if(!E)return null;let I=await A.readFile(E);return(await A.write("uploads.inline",{...I,...B}))?.submissionId??null}function zNA(A){let Q=A==="uploads"?{source:"upload"}:{},B=A==="uploads"?"/inbox?view=uploads":"/inbox?view=receipts";return{key:A,title:A==="uploads"?"Uploads":"Receipts and invoices",action:"inbox.list",pageSize:50,paging:"cursor",views:[{label:"All",input:{...Q,sort:"newest"},href:B},{label:"Ready for review",input:{...Q,sort:"newest",status:"review"},href:B},{label:"Processing",input:{...Q,sort:"newest",status:"processing"},href:B},{label:"Failed",input:{...Q,sort:"newest",status:"failed"},href:B}],read:(E,I)=>g4(E,I),columns:[{label:"Added",width:12,cell:(E)=>mI(E.created_at)},{label:"Receipt",width:"flex",cell:(E)=>MQ(Wu(E))},{label:"From",width:10,optional:!0,cell:(E)=>UB(E.source)},{label:"Status",width:18,cell:(E)=>d0(E.status)}],rowId:(E)=>E.id,rowTitle:Wu,rowHref:()=>B,detail:{action:"submissions.get",input:(E)=>({submissionId:E.id}),lines:(E,I,D)=>{let J=E,G=bD(I.status);return[[{text:Wu(I),bold:!0}],[{text:`● ${G.label}`,color:yU(G.tone)}],...R4(G.summary,D,{color:L.muted}),...wB("Purchases",D),...J.entries?.length?J.entries.map((U)=>[{text:`• ${U.merchant??"Purchase"} `},{text:`${aQ(U.amount_minor,U.currency)} ${oQ(U.date)}`,color:L.muted}]):[[{text:"None yet",color:L.muted}]],...J.evidence?.length?[...wB("Files",D),...J.evidence.map((U)=>[{text:`• ${U.filename??"file"}`,color:L.muted}])]:[]]}},rowActions:[{key:"t",label:"Try again",when:(E)=>E.status==="failed",run:async(E,I)=>{await I.write("submissions.retry",{submissionId:E.id,revision:E.revision}),I.toast("Reading it again","success")}}],listActions:[{key:"U",label:"Upload receipt",run:async(E)=>{if(await gu(E,"Upload a receipt",{}))E.toast("Receipt uploaded. Oatmilk is reading it.","success")}}],empty:"Nothing here yet. Forward receipts to your Oatmilk address or press U to upload one."}}function qNA(A){let Q=A.daysUntil;if(A.status==="done"||A.status==="skipped")return UB(oQ(A.effective_due_date??A.due_date));if(typeof Q==="number"&&Q<0)return MQ(`${-Q}d overdue`,{color:L.danger});if(typeof Q==="number"&&Q<=14)return MQ(Q===0?"Today":`in ${Q}d`,{color:L.warning});return UB(oQ(A.effective_due_date??A.due_date))}function ONA(A){if(A===null||A===void 0||A==="")return"empty";if(typeof A==="string"||typeof A==="number"||typeof A==="boolean")return String(A);return JSON.stringify(A).slice(0,80)}var MQ=(A,Q={})=>({text:A===null||A===void 0||A===""?"—":String(A),...Q}),UB=(A)=>MQ(A,{color:L.muted}),_$=(A,Q,B="")=>MQ(`${B}${aQ(typeof A==="number"?String(A):A,typeof Q==="string"?Q:"CAD")}`),mI=(A)=>UB(typeof A==="string"?oQ(A):"—"),d0=(A)=>{let Q=bD(typeof A==="string"?A:"");return{text:Q.label,color:yU(Q.tone)}},V$=(A)=>A==="admin"||A==="finance",mM=(A,Q="Done from the Oatmilk terminal app.")=>({title:A,label:"Reason (kept in the activity history)",initial:Q,minLength:3}),pBQ,dBQ,iBQ,nBQ,Wu=(A)=>A.provider_metadata?.subject||A.merchants?.[0]||A.claimed_metadata?.filename||"Receipt",aBQ,oBQ,rBQ,sBQ,tBQ,eBQ,A0Q,Q0Q,B0Q,I0Q,E0Q,D0Q,J0Q,ju="/finance/transactions?view=merchants",G0Q,FNA=(A)=>A.endDate&&A.endDate!==A.startDate?`${oQ(A.startDate)} – ${oQ(A.endDate)}`:oQ(A.startDate),MNA=(A)=>A.totalsByCurrency.length?A.totalsByCurrency.map((Q)=>aQ(Q.spentMinor,Q.currency)).join(" · "):"—",C0Q,Ru="/finance/transactions?view=statements",$0Q,U0Q,VNA=(A)=>A.reverted?MQ("Rolled back",{color:L.muted}):A.status==="failed"?MQ("Failed",{color:L.danger}):MQ("Done",{color:L.success}),_NA=(A)=>`${oQ(A)} ${new Date(A).toLocaleTimeString("en-CA",{hour:"numeric",minute:"2-digit"})}`,Y0Q,K0Q,LNA=(A)=>A.status==="active"?MQ("On",{color:L.success}):A.status==="disabled"?MQ("Turned off",{color:L.danger}):UB("Paused"),H0Q,C2;var $2=W(async()=>{Du();o3A();BNA();JNA();ZNA();_u();Lu();d1();bB();await g8();pBQ=[{label:"All",input:{},href:"/finance/transactions"},{label:"Needs you",input:{autopilotState:"needs_you"},href:"/finance/transactions?status=needs_you"},{label:"AI working",input:{autopilotState:"working"},href:"/finance/transactions?status=working"},{label:"Done",input:{autopilotState:"done"},href:"/finance/transactions?status=reviewed"}],dBQ={pdf:"application/pdf",png:"image/png",jpg:"image/jpeg",jpeg:"image/jpeg",webp:"image/webp",heic:"image/heic",heif:"image/heif",eml:"message/rfc822",txt:"text/plain"};iBQ={key:"transactions",title:"Transactions",action:"entries.list",pageSize:50,paging:"offset",probe:!0,searchParam:"search",views:pBQ,read:(A,Q)=>WNA(A,Q),columns:[{label:"Date",width:12,cell:(A)=>mI(A.date)},{label:"Merchant",width:"flex",cell:(A)=>MQ(A.merchant??"Unknown merchant")},{label:"Category",width:22,optional:!0,cell:(A,Q)=>A.category_id?UB(Q.categories.get(A.category_id)??"…"):UB(A.type==="transfer"?"Transfer":"Uncategorized")},{label:"Amount",width:15,align:"right",cell:(A)=>_$(A.amount_minor,A.currency,Eu(A))},{label:"Status",width:18,cell:(A)=>d0(J2(A))}],rowId:(A)=>A.id,rowTitle:(A)=>A.merchant??"Transaction",rowHref:(A)=>`/finance/transactions?entry=${A.id}`,findsRecord:!0,detail:{action:"entries.get",input:(A)=>({id:A.id}),row:(A)=>A.entry??null,lines:(A,Q,B,E)=>{let I=A,D=I.entry??Q,J=bD(J2(D)),G=[[{text:D.merchant??"Unknown merchant",bold:!0}],[{text:`${Eu(D)}${aQ(D.amount_minor,D.currency)}`,color:L.text},{text:` ${oQ(D.date)}`,color:L.muted}],[],[{text:`● ${J.label}`,color:yU(J.tone)}],...R4(J.summary,B,{color:L.muted}),...J.next?eQ([{text:J.next}],B,[{text:"→ ",color:L.accent}]):[],...wB("Details",B),...ME([["Category",D.category_id?E.categories.get(D.category_id)??D.category_id:"Uncategorized"],["Type",D.type],["Tax",D.tax_minor?aQ(D.tax_minor,D.currency):null],["Invoice",D.invoice_number??null],["Tags",D.tags?.length?D.tags.map((U)=>U.name).join(", "):null],["Contractors",D.contractors?.length?D.contractors.map((U)=>U.name).join(", "):null],["Suggested",D.autopilot_suggestion?`${D.autopilot_suggestion.name} (${Math.round(D.autopilot_suggestion.probability*100)}% sure)`:null],["Bank lines",I.allocations?String(I.allocations.length):null],["Evidence",I.evidence?.length?I.evidence.map((U)=>U.filename??U.kind??"file").join(", "):"None yet"],["Emails",I.supportingEmails?.length?String(I.supportingEmails.length):null],["ID",{text:D.id,color:L.faint}]],B)];if(D.notes?.trim())G.push(...wB("Notes",B),...R4(D.notes,B));return G}},rowActions:[{key:"a",label:"Approve",when:(A,Q)=>V$(Q)&&A.status!=="reviewed"&&!A.voided_at,run:async(A,Q)=>{let B=Q.patch({status:"reviewed",autopilot_state:"done"});try{await Q.write("entries.update",{id:A.id,expectedRevision:A.revision,status:"reviewed"}),Q.toast(`Approved ${A.merchant??"the transaction"}`,"success")}catch(E){throw B(),E}}},{key:"c",label:"Categorize",when:(A,Q)=>V$(Q)&&!A.voided_at&&A.type!=="transfer",run:async(A,Q)=>{let B=await Q.categories(),E=await Q.choose({title:`Category for ${A.merchant??"this transaction"}`,items:B.map((D)=>({label:D.path,value:D.id}))});if(!E)return;let I=Q.patch({category_id:E});try{await Q.write("entries.update",{id:A.id,expectedRevision:A.revision,categoryId:E}),Q.toast("Category saved. Oatmilk remembers it for this merchant.","success")}catch(D){throw I(),D}}},{key:"n",label:"Note",when:(A,Q)=>V$(Q)&&!A.voided_at,run:async(A,Q)=>{let B=await Q.prompt({title:"Note",label:`What should the books say about ${A.merchant??"this"}?`,initial:A.notes??""});if(B===null)return;let E=Q.patch({notes:B});try{await Q.write("entries.update",{id:A.id,expectedRevision:A.revision,notes:B}),Q.toast("Note saved","success")}catch(I){throw E(),I}}},{key:"u",label:"Add receipt",when:(A)=>A.status!=="reviewed"&&!A.voided_at,run:async(A,Q)=>{if(await gu(Q,`Receipt for ${A.merchant??"this purchase"}`,{receiptFor:A.id}))Q.toast("Receipt uploaded. Oatmilk is reading it and will match it to this purchase.","success")}}],listActions:[{key:"U",label:"Upload receipt",run:async(A)=>{if(await gu(A,"Upload a receipt",{}))A.toast("Receipt uploaded. Oatmilk is reading it.","success")}}],empty:"No transactions here."},nBQ={key:"email",title:"Email",action:"mail.list",pageSize:30,paging:"offset",searchParam:"search",views:[{label:"All email",input:{archived:!1},href:"/inbox?view=email"},{label:"Unread",input:{archived:!1,read:!1},href:"/inbox?view=email"},{label:"Quarantine",input:{status:"quarantined"},href:"/inbox?view=email&mailStatus=quarantined"},{label:"Archived",input:{archived:!0},href:"/inbox?view=email"}],read:(A,Q)=>g4(A,Q),columns:[{label:"",width:2,cell:(A)=>MQ(A.is_read?" ":"●",{color:L.accent})},{label:"Received",width:12,cell:(A)=>mI(A.received_at)},{label:"From",width:26,optional:!0,cell:(A)=>UB(A.sender_email)},{label:"Subject",width:"flex",cell:(A)=>MQ(A.subject??"(no subject)",{bold:!A.is_read})},{label:"Status",width:18,cell:(A)=>A.fraud_risk&&A.fraud_risk!=="cleared"?MQ("Check sender",{color:L.danger}):d0(A.status)}],rowId:(A)=>A.id,rowTitle:(A)=>A.subject??"Email",rowHref:(A)=>`/inbox?view=email&mail=${A.id}`,findsRecord:!0,detail:{action:"mail.get",input:(A)=>({id:A.id}),row:(A)=>A.message??null,lines:(A,Q,B)=>{let E=A,I=E.message??Q,D=[[{text:I.subject??"(no subject)",bold:!0}],[{text:I.sender_email??"",color:L.muted},{text:` ${oQ(I.received_at)}`,color:L.faint}],[],[d0(I.status),{text:I.purpose?` ${I.purpose}`:"",color:L.muted}]];if(E.review?.question)D.push(...wB("Oatmilk asks",B),...R4(E.review.question,B),...(E.review.choices??[]).map((G)=>[{text:` ${G.id}. `,color:L.muted},{text:G.label}]));let J=E.draft?.facts?.receipts??[];if(J.length)D.push(...wB("What Oatmilk read",B),...J.map((G)=>[{text:`• ${G.merchant??"Receipt"} `,color:L.text},{text:`${G.currency??""} ${G.total??""} ${G.date??""}`,color:L.muted}]));if(E.evidence?.length)D.push(...wB("Attachments",B),...E.evidence.map((G)=>[{text:`• ${G.filename??"attachment"}`,color:L.muted}]));return D}},rowActions:[{key:"m",label:"Read/unread",run:async(A,Q)=>{let B=Q.patch({is_read:!A.is_read});try{await Q.write("mail.update",{id:A.id,expectedRevision:A.revision,read:!A.is_read})}catch(E){throw B(),E}}},{key:"e",label:"Archive",when:(A)=>!A.archived,run:async(A,Q)=>{let B=Q.patch({archived:!0});try{await Q.write("mail.update",{id:A.id,expectedRevision:A.revision,archived:!0}),Q.toast("Archived","success")}catch(E){throw B(),E}}}],empty:"No email here."};aBQ={key:"invoices",title:"Invoices",action:"invoices.list",pageSize:25,paging:"offset",searchParam:"search",views:[{label:"All",input:{},href:"/finance/invoices"},{label:"Unpaid",input:{status:"unpaid"},href:"/finance/invoices"},{label:"Overdue",input:{status:"overdue"},href:"/finance/invoices"},{label:"Drafts",input:{status:"draft"},href:"/finance/invoices"},{label:"Paid",input:{status:"paid"},href:"/finance/invoices"}],read:(A,Q)=>g4(A,Q),columns:[{label:"Number",width:10,cell:(A)=>UB(A.number??"Draft")},{label:"Customer",width:"flex",cell:(A)=>MQ(A.party_name??A.title??"—")},{label:"Due",width:12,optional:!0,cell:(A)=>MQ(A.due_date?oQ(A.due_date):"—",{color:A.overdue?L.danger:L.muted})},{label:"Total",width:15,align:"right",cell:(A)=>_$(A.total_minor,A.currency)},{label:"Balance",width:15,align:"right",optional:!0,cell:(A)=>_$(A.balance_minor??A.total_minor,A.currency)},{label:"Status",width:16,cell:(A)=>d0(A.display_status??A.status)}],rowId:(A)=>A.id,rowTitle:(A)=>`${A.number??"Draft"} · ${A.party_name??""}`,rowHref:(A)=>`/finance/invoices?invoice=${A.id}`,findsRecord:!0,detail:{action:"invoices.get",input:(A)=>({id:A.id}),row:(A)=>A.invoice??null,lines:(A,Q,B)=>{let E=A,I=E.invoice??Q;return[[{text:`Invoice ${I.number??"draft"}`,bold:!0},{text:` ${E.party?.name??I.party_name??""}`,color:L.muted}],[d0(I.display_status??I.status)],...wB("Amounts",B),...ME([["Subtotal",I.subtotal_minor?aQ(I.subtotal_minor,I.currency):null],["Tax",I.tax_minor?aQ(I.tax_minor,I.currency):null],["Total",aQ(I.total_minor,I.currency)],["Paid",I.amount_paid_minor?aQ(I.amount_paid_minor,I.currency):null],["Balance",I.balance_minor?aQ(I.balance_minor,I.currency):null],["Issued",I.issue_date?oQ(I.issue_date):null],["Due",I.due_date?oQ(I.due_date):null],["Sent",I.sent_on?oQ(I.sent_on):null],["Email",E.party?.email??null]],B),...E.payments?.length?[...wB("Payments",B),...E.payments.map((D)=>[{text:`• ${oQ(D.paid_on)} `},{text:aQ(D.amount_minor,I.currency),color:L.success}])]:[]]}},rowActions:[{key:"p",label:"Approve",when:(A)=>A.status==="awaiting_approval",run:async(A,Q)=>{await Q.write("invoices.approve",{id:A.id,expectedRevision:A.revision}),Q.toast("Invoice approved","success")}},{key:"s",label:"Send",when:(A)=>["draft","approved","scheduled"].includes(A.status),run:async(A,Q)=>{if(!await Q.confirm({title:`Email invoice ${A.number??""} to ${A.party_name??"the customer"}?`,body:"Oatmilk sends it from your company's address.",confirmLabel:"Send"}))return;await Q.write("invoices.send",{id:A.id,expectedRevision:A.revision,method:"email"}),Q.toast("Invoice sent","success")}},{key:"v",label:"Void",when:(A)=>!["void","paid"].includes(A.status),run:async(A,Q)=>{if(!await Q.confirm({title:`Void invoice ${A.number??""}?`,body:"A voided invoice stays in the history but no longer counts as owed.",danger:!0,confirmLabel:"Void"}))return;let B=await Q.prompt(mM("Why void it?",""));if(!B)return;await Q.write("invoices.void",{id:A.id,expectedRevision:A.revision,reason:B}),Q.toast("Invoice voided","success")}}],empty:"No invoices here."},oBQ={key:"reimbursements",title:"Reimbursements",action:"reimbursements.list",pageSize:100,paging:"offset",views:[{label:"All",input:{},href:"/finance/reimbursements"},{label:"To review",input:{status:"submitted"},href:"/finance/reimbursements"},{label:"Approved",input:{status:"approved"},href:"/finance/reimbursements"},{label:"Paid",input:{status:"paid"},href:"/finance/reimbursements"}],read:(A,Q)=>g4(A,Q),columns:[{label:"Date",width:12,cell:(A)=>mI(A.purchase?.date)},{label:"Who",width:22,cell:(A)=>MQ(A.claimantName??A.claimantEmail)},{label:"For",width:22,optional:!0,cell:(A)=>UB(A.purchase?.merchant)},{label:"Amount",width:15,align:"right",cell:(A)=>_$(A.amountMinor,A.currency)},{label:"Status",width:14,cell:(A)=>d0(A.status)}],rowId:(A)=>A.id,rowTitle:(A)=>`${A.claimantName??"Reimbursement"} · ${A.purchase?.merchant??""}`,rowHref:()=>"/finance/reimbursements",rowActions:[{key:"p",label:"Approve",when:(A,Q)=>V$(Q)&&A.status==="submitted",run:async(A,Q)=>{if(!await Q.confirm({title:`Approve ${aQ(A.amountMinor,A.currency)} for ${A.claimantName??"them"}?`,body:"You confirm the receipt is valid and they worked here when they bought it.",confirmLabel:"Approve"}))return;let B=Q.patch({status:"approved"});try{await Q.write("reimbursements.approve",{claims:[{id:A.id,expectedRevision:A.revision,receiptValid:!0,employeeAtPurchase:!0}],reason:"Approved from the Oatmilk terminal app."}),Q.toast("Approved","success")}catch(E){throw B(),E}}},{key:"x",label:"Decline",when:(A,Q)=>V$(Q)&&A.status==="submitted",run:async(A,Q)=>{let B=await Q.prompt(mM("Why decline it?",""));if(!B)return;let E=Q.patch({status:"rejected"});try{await Q.write("reimbursements.reject",{id:A.id,expectedRevision:A.revision,reason:B}),Q.toast("Declined","success")}catch(I){throw E(),I}}}],empty:"No reimbursements here."},rBQ={key:"contractors",title:"Contractors",action:"contractorOps.directory.list",pageSize:30,paging:"offset",searchParam:"query",views:[{label:"All",input:{},href:"/people/contractors"},{label:"Active",input:{status:"active"},href:"/people/contractors"},{label:"Onboarding",input:{status:"onboarding"},href:"/people/contractors"},{label:"Inactive",input:{status:"inactive"},href:"/people/contractors"}],read:(A,Q)=>g4(A,Q),columns:[{label:"Name",width:"flex",cell:(A)=>MQ(A.displayName)},{label:"Role",width:22,optional:!0,cell:(A)=>UB(A.title??A.department)},{label:"Rate",width:18,align:"right",cell:(A)=>A.rate?MQ(`${aQ(A.rate.amountMinor,A.rate.currency)}/${A.rate.unit.replace(/^per_/,"")}`):UB("—")},{label:"Next due",width:12,optional:!0,cell:(A)=>mI(A.nextDueDate)},{label:"Status",width:12,cell:(A)=>d0(A.status)}],rowId:(A)=>A.contractorId,rowTitle:(A)=>A.displayName,rowHref:(A)=>`/people/contractors?contractor=${A.contractorId}`,findsRecord:!0,detail:{action:"contractorOps.profiles.get",input:(A)=>({contractorId:A.contractorId}),lines:(A,Q,B)=>[[{text:Q.displayName,bold:!0}],[{text:Q.email??"",color:L.muted}],[],...ME([["Status",d0(Q.status)],["Role",Q.title],["Department",Q.department],["Rate",Q.rate?`${aQ(Q.rate.amountMinor,Q.rate.currency)} ${Q.rate.unit.replace(/_/g," ")}`:null],["Next due",Q.nextDueDate?oQ(Q.nextDueDate):null],["Hours to review",Q.pendingEntries?String(Q.pendingEntries):null],["Unpaid hours",Q.unpaidEntries?String(Q.unpaidEntries):null]],B)]},empty:"No contractors here."},sBQ={key:"timesheets",title:"Timesheets",action:"contractorOps.timesheets.list",pageSize:30,paging:"offset",views:[{label:"To review",input:{status:"awaiting"},href:"/people/contractors?view=timesheets"},{label:"Open",input:{status:"open"},href:"/people/contractors?view=timesheets"},{label:"Approved",input:{status:"approved"},href:"/people/contractors?view=timesheets"},{label:"All",input:{status:"all"},href:"/people/contractors?view=timesheets"}],read:(A,Q)=>g4(A,Q),columns:[{label:"Contractor",width:"flex",cell:(A)=>MQ(A.contractorName)},{label:"Period",width:26,cell:(A)=>UB(`${oQ(A.periodStart)} – ${oQ(A.periodEnd)}`)},{label:"Hours",width:8,align:"right",cell:(A)=>MQ(((A.stats?.submittedMinutes??0)/60).toFixed(1))},{label:"Pay date",width:12,optional:!0,cell:(A)=>mI(A.payDate)},{label:"Status",width:12,cell:(A)=>d0(A.status)}],rowId:(A)=>A.id,rowTitle:(A)=>`${A.contractorName} · ${oQ(A.periodStart)}`,rowHref:()=>"/people/contractors?view=timesheets",detail:{action:"contractorOps.timesheets.list",input:(A)=>({periodId:A.id}),lines:(A,Q,B)=>{let E=A;return[[{text:Q.contractorName,bold:!0},{text:` ${oQ(Q.periodStart)} – ${oQ(Q.periodEnd)}`,color:L.muted}],[d0(Q.status)],...wB("Hours",B),...E.entries?.length?E.entries.flatMap((I)=>eQ([{text:`${oQ(I.date)} `,color:L.muted},{text:`${(I.minutes/60).toFixed(2)} h `},{text:I.description??"",color:L.muted},{text:` ${bD(I.status).label}`,color:L.faint}],B)):[[{text:"No hours logged",color:L.muted}]]]}},rowActions:[{key:"p",label:"Approve hours",when:(A)=>A.status==="submitted",run:async(A,Q)=>{let E=((await Q.read("contractorOps.timesheets.list",{periodId:A.id})).entries??[]).filter((I)=>I.status==="submitted");if(!E.length){Q.toast("There are no submitted hours to approve.","info");return}if(!await Q.confirm({title:`Approve ${E.length} ${E.length===1?"entry":"entries"} for ${A.contractorName}?`,confirmLabel:"Approve"}))return;await Q.write("contractorOps.timesheets.review",{periodId:A.id,reason:"Approved from the Oatmilk terminal app.",decisions:E.map((I)=>({hoursId:I.id,expectedRevision:I.revision,decision:"approved"}))}),Q.toast("Hours approved","success")}}],empty:"No timesheets here."},tBQ={key:"agreements",title:"Agreements",action:"signing.envelopes.list",pageSize:25,paging:"offset",searchParam:"query",views:[{label:"All",input:{},href:"/legal/agreements"},{label:"Waiting",input:{status:"open"},href:"/legal/agreements"},{label:"Needs attention",input:{status:"attention"},href:"/legal/agreements"},{label:"Waiting on me",input:{awaitingMe:!0},href:"/legal/agreements"},{label:"Completed",input:{status:"completed"},href:"/legal/agreements"}],read:(A,Q)=>g4(A,Q),columns:[{label:"Agreement",width:"flex",cell:(A)=>MQ(A.title)},{label:"With",width:22,optional:!0,cell:(A)=>UB(A.subjectName??A.recipients?.map((Q)=>Q.name??Q.email).join(", "))},{label:"Signed",width:8,align:"right",cell:(A)=>MQ(`${A.signedCount}/${A.signerCount}`,{color:A.signedCount===A.signerCount&&A.signerCount>0?L.success:L.muted})},{label:"Sent",width:12,optional:!0,cell:(A)=>mI(A.sentAt)},{label:"Status",width:14,cell:(A)=>A.awaitingMe?MQ("Sign now",{color:L.warning}):d0(A.status)}],rowId:(A)=>A.id,rowTitle:(A)=>A.title,rowHref:(A)=>`/legal/agreements/${A.id}`,findsRecord:!0,detail:{action:"signing.envelopes.get",input:(A)=>({id:A.id}),row:(A)=>{let Q=A;return Q.envelope??(Q.id?Q:null)},lines:(A,Q,B)=>{let E=A,I="envelope"in E&&E.envelope?E.envelope:E,D=I.recipients??Q.recipients??[];return[[{text:I.title??Q.title,bold:!0}],[d0(I.status??Q.status)],...wB("Signers",B),...D.map((J)=>[{text:`${J.status==="signed"||J.status==="completed"?"✓":"○"} `,color:J.status==="signed"||J.status==="completed"?L.success:L.muted},{text:J.name??J.email},{text:` ${bD(J.status).label}`,color:L.muted}]),...Q.awaitingMe&&Q.signUrl?[[],[{text:"You sign this yourself in the browser: press o.",color:L.warning}]]:[]]}},rowActions:[{key:"m",label:"Remind",when:(A)=>["sent","in_progress"].includes(A.status),run:async(A,Q)=>{if(!await Q.confirm({title:`Email a reminder about "${A.title}"?`,confirmLabel:"Remind"}))return;await Q.write("signing.envelopes.remind",{id:A.id,expectedRevision:A.revision}),Q.toast("Reminder sent","success")}},{key:"v",label:"Void",when:(A)=>!["completed","voided","declined","expired"].includes(A.status),run:async(A,Q)=>{if(!await Q.confirm({title:`Void "${A.title}"?`,body:"Signers can no longer sign it.",danger:!0,confirmLabel:"Void"}))return;let B=await Q.prompt(mM("Why void it?",""));if(!B)return;await Q.write("signing.envelopes.void",{id:A.id,expectedRevision:A.revision,reason:B}),Q.toast("Voided","success")}}],empty:"No agreements here."};eBQ={key:"checklist",title:"Checklist",action:"compliance.checklist",pageSize:500,paging:"none",views:[{label:"Open",input:{includeDone:!1},href:"/checklist"},{label:"Everything",input:{includeDone:!0},href:"/checklist"}],read:(A)=>({rows:A.items??[],hasMore:!1}),columns:[{label:"Due",width:14,cell:qNA},{label:"What",width:"flex",cell:(A)=>MQ(A.title,{strikethrough:A.status==="done"})},{label:"Area",width:14,optional:!0,cell:(A)=>UB(A.category.replace(/_/g," "))},{label:"Status",width:14,cell:(A)=>d0(A.status)}],rowId:(A)=>A.id,rowTitle:(A)=>A.title,rowHref:(A)=>`/checklist?item=${A.id}`,findsRecord:!0,detail:{action:"compliance.items.get",input:(A)=>({id:A.id}),row:(A)=>A.item??null,lines:(A,Q,B)=>{let I=A.item??Q;return[[{text:I.title,bold:!0}],[qNA(I),{text:` ${bD(I.status).label}`,color:L.muted}],...I.what?[...wB("What to do",B),...R4(I.what,B)]:[],...I.why?[...wB("Why",B),...R4(I.why,B,{color:L.muted})]:[],..."notes"in I&&I.notes?[...wB("Notes",B),...R4(I.notes,B)]:[],[],[{text:"Resolve it here: d done · s skip · p in progress",color:L.faint}]]}},rowActions:[{key:"d",label:"Done",when:(A)=>A.status!=="done",run:async(A,Q)=>{let B=Q.patch({status:"done"});try{await Q.write("compliance.items.update",{id:A.id,expectedRevision:A.revision,status:"done"}),Q.toast(`Marked "${A.title}" done`,"success")}catch(E){throw B(),E}}},{key:"s",label:"Skip",when:(A)=>A.status!=="skipped"&&A.status!=="done",run:async(A,Q)=>{let B=Q.patch({status:"skipped"});try{await Q.write("compliance.items.update",{id:A.id,expectedRevision:A.revision,status:"skipped"}),Q.toast("Skipped","success")}catch(E){throw B(),E}}},{key:"p",label:"In progress",when:(A)=>A.status==="upcoming",run:async(A,Q)=>{let B=Q.patch({status:"in_progress"});try{await Q.write("compliance.items.update",{id:A.id,expectedRevision:A.revision,status:"in_progress"})}catch(E){throw B(),E}}}],empty:"Nothing due. Oatmilk adds deadlines as they come up."},A0Q={key:"matching",title:"Receipt matching",action:"matching.list",pageSize:25,paging:"offset",views:[{label:"To review",input:{outcome:"review"},href:"/finance/reconcile?view=matching"},{label:"Unmatched",input:{outcome:"unmatched"},href:"/finance/reconcile?view=matching"},{label:"Matched",input:{outcome:"matched"},href:"/finance/reconcile?view=matching"}],read:(A,Q)=>g4(A,Q),columns:[{label:"Date",width:12,cell:(A)=>mI(A.entry?.date)},{label:"Receipt",width:"flex",cell:(A)=>MQ(A.entry?.merchant??"Receipt")},{label:"Amount",width:15,align:"right",cell:(A)=>_$(A.entry?.amount_minor,A.entry?.currency)},{label:"Matches",width:9,align:"right",optional:!0,cell:(A)=>UB(String(A.details?.candidates?.length??0))},{label:"Outcome",width:12,cell:(A)=>d0(A.outcome)}],rowId:(A)=>A.id,rowTitle:(A)=>A.entry?.merchant??"Receipt",rowHref:()=>"/finance/reconcile?view=matching",empty:"No receipts waiting for a match."},Q0Q={key:"bank",title:"Bank transactions",action:"transactions.list",pageSize:50,paging:"offset",probe:!0,searchParam:"search",views:[{label:"All",input:{},href:"/finance/reconcile?view=bank"},{label:"Unmatched",input:{allocation:"unmatched"},href:"/finance/reconcile?view=bank"},{label:"Money in",input:{direction:"in"},href:"/finance/reconcile?view=bank"},{label:"Money out",input:{direction:"out"},href:"/finance/reconcile?view=bank"}],read:(A,Q)=>WNA(A,Q),columns:[{label:"Date",width:12,cell:(A)=>mI(A.date)},{label:"Description",width:"flex",cell:(A)=>MQ(A.description??A.reference)},{label:"Amount",width:16,align:"right",cell:(A)=>MQ(aQ(A.amount_minor,A.currency),{color:A.amount_minor.startsWith("-")?L.text:L.success})},{label:"Matched",width:10,optional:!0,cell:(A)=>A.allocated_minor&&A.allocated_minor.replace("-","")===A.amount_minor.replace("-","")?MQ("Matched",{color:L.success}):A.allocated_minor&&A.allocated_minor!=="0"?MQ("Partly",{color:L.warning}):UB("No")}],rowId:(A)=>A.id,rowTitle:(A)=>A.description??"Bank transaction",rowHref:()=>"/finance/reconcile?view=bank",detail:{action:"transactions.get",input:(A)=>({id:A.id}),lines:(A,Q,B)=>[[{text:Q.description??"Bank transaction",bold:!0}],[{text:aQ(Q.amount_minor,Q.currency)},{text:` ${oQ(Q.date)}`,color:L.muted}],...ME([["Reference",Q.reference??null],["Matched",Q.allocated_minor?aQ(Q.allocated_minor,Q.currency):"Nothing yet"]],B)]},empty:"No bank transactions here."},B0Q={key:"stripe",title:"Stripe payouts",action:"stripe.payouts.list",pageSize:50,paging:"offset",views:[{label:"All",input:{},href:"/finance/reconcile?view=stripe"},{label:"Paid",input:{status:"paid"},href:"/finance/reconcile?view=stripe"},{label:"In transit",input:{status:"in_transit"},href:"/finance/reconcile?view=stripe"}],read:(A,Q)=>g4(A,Q),columns:[{label:"Arrives",width:12,cell:(A)=>mI(A.arrival_date)},{label:"Amount",width:16,align:"right",cell:(A)=>_$(A.amount_minor,A.currency)},{label:"Matched",width:"flex",cell:(A)=>A.allocated_minor&&A.allocated_minor===A.amount_minor?MQ("Matched to a deposit",{color:L.success}):MQ("Not matched yet",{color:L.warning})},{label:"Status",width:12,cell:(A)=>d0(A.status)}],rowId:(A)=>A.id,rowTitle:(A)=>`Payout ${oQ(A.arrival_date)}`,rowHref:()=>"/finance/reconcile?view=stripe",empty:"No Stripe payouts. Connect Stripe in Settings to see them."},I0Q={key:"subscriptions",title:"Subscriptions",action:"subscriptions.list",pageSize:1000,paging:"none",views:[{label:"All",input:{},href:"/finance/subscriptions"}],read:(A)=>({rows:A.items??[],hasMore:!1}),columns:[{label:"Service",width:"flex",cell:(A)=>MQ(A.merchant)},{label:"Every",width:10,optional:!0,cell:(A)=>UB(A.effectiveCadence??A.cadence)},{label:"Last paid",width:12,optional:!0,cell:(A)=>mI(A.lastPaidOn)},{label:"Next",width:12,cell:(A)=>mI(A.nextExpectedOn)},{label:"Per year",width:15,align:"right",cell:(A)=>_$(A.annualizedMinor,A.currency)},{label:"Status",width:16,cell:(A)=>d0(A.effectiveStatus)}],rowId:(A)=>A.key??A.vendorKey??A.merchant,rowTitle:(A)=>A.merchant,rowHref:()=>"/finance/subscriptions",empty:"No subscriptions found in your spending yet."},E0Q={key:"postings",title:"Job postings",action:"recruiting.postings.list",pageSize:500,paging:"none",views:[{label:"All",input:{},href:"/people/recruiting"}],read:(A)=>({rows:A.items??[],hasMore:!1}),columns:[{label:"Role",width:"flex",cell:(A)=>MQ(A.title)},{label:"Team",width:18,optional:!0,cell:(A)=>UB(A.department)},{label:"Where",width:16,optional:!0,cell:(A)=>UB(A.location)},{label:"People",width:8,align:"right",cell:(A)=>MQ(String(A.counts?.total??0))},{label:"New",width:5,align:"right",cell:(A)=>MQ(String(A.counts?.new??0),{color:A.counts?.new?L.highlight:L.muted})},{label:"Status",width:10,cell:(A)=>d0(A.status)}],rowId:(A)=>A.id,rowTitle:(A)=>A.title,rowHref:()=>"/people/recruiting",empty:"No job postings yet."},D0Q={key:"accounts",title:"Accounts",action:"accounts.list",pageSize:1000,paging:"none",views:[{label:"All",input:{},href:"/finance/transactions?view=accounts"}],read:(A)=>({rows:A,hasMore:!1}),columns:[{label:"Account",width:"flex",cell:(A)=>MQ(A.name,{color:A.active?L.text:L.muted})},{label:"Kind",width:14,cell:(A)=>UB((A.account_type??"").replace(/_/g," "))},{label:"Bank",width:12,optional:!0,cell:(A)=>UB(A.provider)},{label:"Currency",width:9,cell:(A)=>UB(A.currency)}],rowId:(A)=>A.id,rowTitle:(A)=>A.name,rowHref:()=>"/finance/transactions?view=accounts",empty:"No accounts yet. Connect a bank in Settings."},J0Q={key:"api-keys",title:"API keys",action:"api_keys.list",pageSize:100,paging:"offset",views:[{label:"Yours",input:{},href:"/settings?section=developers"}],read:(A,Q)=>g4(A,Q),columns:[{label:"Name",width:"flex",cell:(A)=>MQ(A.name,{strikethrough:!!A.revoked_at})},{label:"Key",width:22,cell:(A)=>UB(`${A.token_prefix}…${A.token_last_four}`)},{label:"Expires",width:12,cell:(A)=>mI(A.expires_at)},{label:"Last used",width:12,optional:!0,cell:(A)=>mI(A.last_used_at)},{label:"",width:9,cell:(A)=>A.revoked_at?MQ("Revoked",{color:L.danger}):MQ("Active",{color:L.success})}],rowId:(A)=>A.id,rowTitle:(A)=>A.name,rowHref:()=>"/settings?section=developers",rowActions:[{key:"x",label:"Revoke",when:(A)=>!A.revoked_at,run:async(A,Q)=>{if(!await Q.confirm({title:`Revoke "${A.name}"?`,body:"Anything using this key stops working at once.",danger:!0,confirmLabel:"Revoke"}))return;let B=Q.patch({revoked_at:new Date().toISOString()});try{await Q.write("api_keys.revoke",{id:A.id,expectedRevision:A.revision}),Q.toast("Key revoked","success")}catch(E){throw B(),E}}}],listActions:[{key:"N",label:"New key",run:async(A)=>{let Q=await A.prompt({title:"New API key",label:"Name it after what will use it",placeholder:"Nightly export script",minLength:1});if(!Q)return;let B=await A.choose({title:"What may it do?",items:[{label:"Read and change the books",value:["accounting:read","accounting:write"],detail:"accounting:read, accounting:write"},{label:"Only read the books",value:["accounting:read"],detail:"accounting:read"},{label:"Read and change the books and company email",value:["accounting:read","accounting:write","mail:read","mail:write"],detail:"adds mail:read, mail:write"}]});if(!B)return;let E=await A.write("api_keys.create",{name:Q,scopes:B});if(E.secret)await A.showSecret("Copy your new key now",E.secret,"Oatmilk shows it only once. Use it as OATMILK_API_KEY or with oatmilk login --api-key.")}}],empty:"No API keys yet. Press N to create one."},G0Q={key:"merchants",title:"Merchants",action:"merchants.list",pageSize:50,paging:"offset",searchParam:"search",views:[{label:"All merchants",input:{filter:"all"},href:ju},{label:"Needs a look",input:{filter:"needs_look"},href:ju}],read:(A,Q)=>g4(A,Q),columns:[{label:"Merchant",width:"flex",cell:(A)=>MQ(A.displayName)},{label:"Category",width:22,optional:!0,cell:(A)=>A.category?UB(A.category.name):UB("None yet")},{label:"Spent, 12 months",width:17,align:"right",cell:(A)=>MQ(Cu(A.spend))},{label:"Last paid",width:12,optional:!0,cell:(A)=>mI(A.lastPaid)},{label:"",width:13,cell:(A)=>A.needsLook.length?MQ("Needs a look",{color:L.warning}):{text:""}}],rowId:(A)=>A.key,rowTitle:(A)=>A.displayName,rowHref:(A)=>`${ju}&merchant=${encodeURIComponent(A.key)}`,findsRecord:!0,detail:{action:"merchants.get",input:(A)=>({key:A.key}),row:(A)=>A.merchant??null,lines:(A,Q,B)=>{let E=A,I=E.merchant??Q,D=i3A(I.spend),J=[[{text:I.displayName,bold:!0}],...xM(I)?[[{text:xM(I),color:L.muted}]]:[],...I.needsLook.length?[[],...eQ([{text:a3A(I.needsLook),color:L.warning}],B)]:[],...R4(I.description,B),...wB("Details",B),...ME([["Category",I.category?I.category.name:"None yet"],["Why",I.category?n3A[I.category.source]:null],["Spent",Cu(I.spend)],["Also",D||null],["Last paid",I.lastPaid?oQ(I.lastPaid):null],["Purchases",String(I.entryCount)],["To review",I.unreviewedCount?String(I.unreviewedCount):null],["Other names",I.aliases.length>1?I.aliases.slice(0,6).join(", "):null]],B)];if(E.suggestion)J.push(...wB("Oatmilk suggests",B),...eQ([{text:E.suggestion.categoryName,bold:!0}],B),...R4(E.suggestion.reasoning,B,{color:L.muted}));if(E.transactions?.length)J.push(...wB("Latest purchases",B),...E.transactions.map((G)=>[{text:`${oQ(G.date)} `,color:L.muted},{text:aQ(G.amountMinor,G.currency)}]));return J}},rowActions:[{key:"f",label:"Confirm",when:(A,Q)=>V$(Q)&&A.unconfirmedFields.length>0,run:async(A,Q)=>{if(!await Q.confirm({title:`Confirm what Oatmilk filled in for ${A.displayName}?`,body:[xM(A),A.description].filter(Boolean).join(". ")||"Oatmilk won't change a confirmed profile later.",confirmLabel:"Confirm"}))return;let B=Q.patch({unconfirmedFields:[],needsLook:A.needsLook.filter((E)=>E!=="unconfirmed_profile")});try{await Q.write("merchants.confirm",{key:A.key,...A.revision?{expectedRevision:A.revision}:{}}),Q.toast("Profile confirmed","success")}catch(E){throw B(),E}}}],empty:"No merchants yet. Everyone you pay shows up here once a purchase is recorded."},C0Q={key:"trips",title:"Trips",action:"trips.list",pageSize:1000,paging:"none",views:[{label:"All",input:{},href:"/finance/transactions?view=trips"}],read:(A)=>({rows:A.items??[],hasMore:!1}),columns:[{label:"Trip",width:"flex",cell:(A)=>MQ(A.title)},{label:"Where",width:20,optional:!0,cell:(A)=>UB(A.placeLabel)},{label:"When",width:26,cell:(A)=>UB(FNA(A))},{label:"Cost",width:16,align:"right",cell:(A)=>MQ(MNA(A))},{label:"Status",width:10,cell:(A)=>d0(A.status)}],rowId:(A)=>A.id,rowTitle:(A)=>A.title,rowHref:(A)=>`/finance/transactions?view=trips&trip=${A.id}`,findsRecord:!0,detail:{action:"trips.get",input:(A)=>({id:A.id}),row:(A)=>A.trip??null,lines:(A,Q,B)=>{let E=A,I=E.trip??Q;return[[{text:I.title,bold:!0}],[{text:[I.placeLabel,FNA(I)].filter(Boolean).join(" "),color:L.muted}],[],...ME([["Status",d0(I.status)],["Cost",MNA(I)],["Purchases",String(I.entryCount)]],B),...wB("Purchases",B),...E.entries?.length?E.entries.flatMap((D)=>eQ([{text:`${oQ(D.date)} `,color:L.muted},{text:`${D.merchant} `},{text:aQ(D.amountMinor,D.currency)},{text:` ${D.role.replace(/_/g," ")}`,color:L.faint}],B)):[[{text:E.trip?"None yet":"…",color:L.muted}]]]}},empty:"No trips yet. Oatmilk groups purchases made while you travel into trips."},$0Q={key:"statements",title:"Statements",action:"statements.list",pageSize:50,paging:"offset",searchParam:"search",views:[{label:"All",input:{allPeriods:!0},href:Ru},{label:"To check",input:{allPeriods:!0,status:"check"},href:Ru}],read:(A,Q)=>g4(A,Q),columns:[{label:"Account",width:"flex",cell:(A)=>MQ(hM(A))},{label:"Period",width:22,cell:(A)=>UB(uM(A))},{label:"From",width:11,optional:!0,cell:(A)=>UB(Nu[A.source])},{label:"Added",width:12,optional:!0,cell:(A)=>mI(A.addedAt)},{label:"Status",width:18,cell:(A)=>MQ(A.statusLabel,{color:yU(zu(A))})}],rowId:(A)=>A.id,rowTitle:(A)=>`${hM(A)} · ${uM(A)}`,rowHref:(A)=>`${Ru}&statement=${A.id}`,findsRecord:!0,detail:{action:"statements.lines",input:(A)=>({id:A.id}),row:(A)=>A.statement??null,lines:(A,Q,B)=>{let E=A,I=E.statement??Q,D=(G)=>G&&I.currency?aQ(G,I.currency):null,J=[[{text:hM(I),bold:!0}],[{text:uM(I),color:L.muted}],[],[{text:`● ${I.statusLabel}`,color:yU(zu(I))}],...R4(I.reason,B,{color:L.muted}),...wB("Details",B),...ME([["File",I.filename],["From",Nu[I.source]],["Bank",I.bank],["Opening",D(I.openingMinor)],["Closing",D(I.closingMinor)],["Lines",I.lines.total===null?null:String(I.lines.total)],["New lines",I.lines.imported===null?null:String(I.lines.imported)],["Added",oQ(I.addedAt)],["Checked",E.statement?E.verified?"Lines add up to its balances":"Not checked against its balances":null]],B)];if(I.warnings.length)J.push(...wB("The reader wasn't sure about",B),...I.warnings.flatMap((G)=>eQ([{text:`• ${G}`,color:L.muted}],B)));if(E.note)J.push([],...R4(E.note,B,{color:L.muted}));return J}},empty:"No statements yet. Upload one in the browser (press o), or connect Wise in Settings."},U0Q=[["People","people",["web","portal","signer"]],["AI and apps","ai",["assistant","mcp","api"]],["Automatic","automatic",["automation"]]],Y0Q={key:"history",title:"History",action:"history.list",pageSize:50,paging:"cursor",searchParam:"query",views:[{label:"Everyone",input:{},href:"/history"},...U0Q.map(([A,Q,B])=>({label:A,input:{sources:B},href:`/history?who=${Q}`})),{label:"Failed",input:{statuses:["failed"]},href:"/history?status=failed"}],read:(A,Q)=>g4(A,Q),columns:[{label:"When",width:20,cell:(A)=>UB(_NA(A.at))},{label:"Who",width:18,cell:(A)=>MQ(A.actor.name)},{label:"What",width:"flex",cell:(A)=>MQ(A.subject?`${A.title}: ${A.subject}`:A.title)},{label:"Area",width:14,optional:!0,cell:(A)=>UB(Fu(A.area))},{label:"Status",width:12,cell:VNA}],rowId:(A)=>A.id,rowTitle:(A)=>A.title,rowHref:(A)=>`/history?event=${A.id}`,findsRecord:!0,detail:{action:"history.get",input:(A)=>({id:A.id}),row:(A)=>A.id?A:null,lines:(A,Q,B)=>{let E=A,I=E.id?E:Q,D=[[{text:I.title,bold:!0}],...I.subject?[[{text:I.subject,color:L.muted}]]:[],[],[VNA(I)],...I.error?.message?eQ([{text:I.error.message,color:L.danger}],B):[],...wB("Details",B),...ME([["Who",I.actor.email?`${I.actor.name} (${I.actor.email})`:I.actor.name],["When",_NA(I.at)],["How",DNA[I.source]],["Area",Fu(I.area)],["Records",I.targets>1?String(I.targets):null],["Action",{text:I.action,color:L.faint}]],B)];if(E.changes?.length)D.push(...wB("What changed",B),...E.changes.slice(0,20).flatMap((J)=>eQ([{text:`${J.label} `,color:L.muted},{text:ONA(J.before),strikethrough:!0,color:L.faint},{text:" → "},{text:ONA(J.after)}],B)));if(E.rollbacks?.length)D.push(...wB("Rolled back",B),...E.rollbacks.map((J)=>[{text:`${oQ(J.at)} `,color:L.muted},{text:`${J.actor.name}: ${J.reason??J.title}`}]));return D}},rowActions:[{key:"z",label:"Roll back",when:(A,Q)=>V$(Q)&&A.canRollBack&&!A.reverted,run:async(A,Q)=>{let B=await Q.read("history.rollback.preview",{id:A.id});if(B.state!=="ready"&&B.state!=="partial"){Q.toast(B.summary||"This change can't be rolled back.","info");return}if(!await Q.confirm({title:`Roll back "${A.title}"?`,body:[B.summary,...B.warnings].filter(Boolean).join(" "),danger:!0,confirmLabel:"Roll back"}))return;let E=await Q.prompt(mM("Why roll it back?",""));if(!E)return;let I=await Q.write("history.rollback.apply",{id:A.id,previewFingerprint:B.previewFingerprint,reason:E});Q.toast(I.message||"Rolled back",I.state==="rolledBack"?"success":"warning")}}],empty:"No changes yet. Everything anyone changes shows up here."};K0Q={key:"compliance-items",title:"Open items",action:"compliancePortal.overview",pageSize:1000,paging:"none",views:[{label:"All",input:{},href:"/compliance?view=items"}],read:(A)=>({rows:A.openItems??[],hasMore:!1}),columns:[{label:"Kind",width:22,cell:(A)=>UB(Ou[A.kind])},{label:"Item",width:"flex",cell:(A)=>MQ(A.title)},{label:"Topic",width:18,optional:!0,cell:(A)=>UB(Vu(A.topic).label)},{label:"From",width:12,optional:!0,cell:(A)=>mI(A.effectiveDate)}],rowId:(A)=>A.key,rowTitle:(A)=>A.title,rowHref:()=>"/compliance?view=items",detail:{action:"compliancePortal.overview",input:()=>({}),lines:(A,Q,B)=>[[{text:Q.title,bold:!0}],[{text:`${Ou[Q.kind]} · ${Vu(Q.topic).label}`,color:L.muted}],...Q.summary?[[],...R4(Q.summary,B)]:[],...Q.kind==="setting_change"?[...wB("The setting",B),...ME([["Now",Q.currentValue||"Not set"],["Suggested",Q.proposedValue||"Not set"]],B)]:[],...wB("Details",B),...ME([["In force",Q.effectiveDate?oQ(Q.effectiveDate):null],["Source",Q.citation?.title??null],["Link",Q.citation?.url??null],["Added",oQ(Q.createdAt)]],B),[],[{text:`${XNA[Q.kind]} it in the browser: press o.`,color:L.faint}]]},empty:"Nothing to decide. Rules that may change how your company is set up show up here."},H0Q={key:"webhooks",title:"Webhooks",action:"webhooks.endpoints.list",pageSize:100,paging:"none",views:[{label:"All",input:{},href:"/developers?view=webhooks"}],read:(A)=>({rows:A.items??[],hasMore:!1}),columns:[{label:"Address",width:"flex",cell:(A)=>MQ(A.url)},{label:"Events",width:8,align:"right",cell:(A)=>UB(A.events.includes("*")?"All":String(A.events.length))},{label:"Sent, 7 days",width:13,align:"right",optional:!0,cell:(A)=>MQ(String(A.recent?.delivered??0))},{label:"Failed",width:7,align:"right",cell:(A)=>MQ(String(A.recent?.failed??0),{color:A.recent?.failed?L.danger:L.muted})},{label:"Status",width:11,cell:LNA}],rowId:(A)=>A.id,rowTitle:(A)=>A.url,rowHref:()=>"/developers?view=webhooks",detail:{action:"webhooks.deliveries.list",input:(A)=>({endpointId:A.id,limit:10}),lines:(A,Q,B)=>{let E=A.items;return[[{text:Q.url,bold:!0}],...Q.description?[[{text:Q.description,color:L.muted}]]:[],[],[LNA(Q)],...Q.disabled_reason?R4(Q.disabled_reason,B,{color:L.danger}):[],...wB("Details",B),...ME([["Events",Q.events.join(", ")],["Secret",{text:`…${Q.secret_hint}`,color:L.faint}],["Last sent",Q.last_delivery_at?oQ(Q.last_delivery_at):"Never"],["Last worked",Q.last_success_at?oQ(Q.last_success_at):null],["Fails in a row",Q.failure_count?String(Q.failure_count):null]],B),...wB("Latest deliveries",B),...E===void 0?[[{text:"…",color:L.muted}]]:E.length?E.map((I)=>[{text:`${oQ(I.created_at)} `,color:L.muted},{text:`${I.event_type}${I.test?" (test)":""} `},d0(I.status),{text:I.response_status?` ${I.response_status}`:"",color:L.faint}]):[[{text:"None yet",color:L.muted}]]]}},rowActions:[{key:"p",label:"Pause/turn on",when:(A,Q)=>Q==="admin",run:async(A,Q)=>{let B=!A.active;if(!await Q.confirm({title:B?`Turn on ${A.url}?`:`Pause ${A.url}?`,body:B?"Oatmilk sends events to it again.":"Oatmilk stops sending events to it until you turn it back on.",danger:!B,confirmLabel:B?"Turn on":"Pause"}))return;let E=Q.patch({active:B,status:B?"active":"paused"});try{await Q.write("webhooks.endpoints.update",{id:A.id,expectedRevision:A.revision,active:B}),Q.toast(B?"Webhook on":"Webhook paused","success")}catch(I){throw E(),I}}}],empty:"No webhooks yet. Add one in the browser (press o)."},C2={transactions:iBQ,email:nBQ,receipts:zNA("receipts"),uploads:zNA("uploads"),invoices:aBQ,reimbursements:oBQ,contractors:rBQ,timesheets:sBQ,agreements:tBQ,checklist:eBQ,matching:A0Q,bank:Q0Q,stripe:B0Q,subscriptions:I0Q,postings:E0Q,accounts:D0Q,"api-keys":J0Q,merchants:G0Q,trips:C0Q,statements:$0Q,history:Y0Q,"compliance-items":K0Q,webhooks:H0Q}});function P8(A){return`${A.getFullYear()}-${String(A.getMonth()+1).padStart(2,"0")}-${String(A.getDate()).padStart(2,"0")}`}function RNA(A=new Date){let Q=A.getFullYear(),B=A.getMonth(),E=Math.floor(B/3)*3;return[{label:"This month",from:P8(new Date(Q,B,1)),to:P8(A)},{label:"Last month",from:P8(new Date(Q,B-1,1)),to:P8(new Date(Q,B,0))},{label:"This quarter",from:P8(new Date(Q,E,1)),to:P8(A)},{label:"Year to date",from:P8(new Date(Q,0,1)),to:P8(A)},{label:"Last year",from:P8(new Date(Q-1,0,1)),to:P8(new Date(Q-1,11,31))}]}function Pu(A,Q,B){if(Q<=0||A<=0||B<=0)return"";let E=Math.max(1,Math.round(A/Q*B*8)),I=["","▏","▎","▍","▌","▋","▊","▉"];return"█".repeat(Math.floor(E/8))+I[E%8]}function X0Q({labels:A,index:Q}){return R(O4,{line:A.flatMap((B,E)=>[{text:` ${B} `,color:E===Q?L.text:L.muted,bold:E===Q,underline:E===Q},{text:" "}])})}function Su({title:A,tabs:Q,tab:B,onTab:E,lines:I,loading:D,error:J,width:G,height:U,hints:Y}){let H=FB(),[X,N]=tE.useState(0),[z,F]=tE.useState(B);if(z!==B)F(B),N(0);let{setHints:V}=H;tE.useEffect(()=>{V(Y)},[Y,V]);let O=Math.max(1,U-2);return iQ((j,b)=>{if(j==="]")E((B+1)%Q.length);else if(j==="[")E((B+Q.length-1)%Q.length);else if(b.downArrow||j==="j")N((x)=>Math.min(Math.max(0,I.length-O),x+1));else if(b.upArrow||j==="k")N((x)=>Math.max(0,x-1));else if(b.pageDown)N((x)=>Math.min(Math.max(0,I.length-O),x+O-1));else if(b.pageUp)N((x)=>Math.max(0,x-O+1));else if(b.escape||b.leftArrow)H.setFocus(H.layout.sidebarWidth?"sidebar":"composer");else if(j==="R")H.store.invalidate();else if(j==="o")H.openInBrowser(H.route.href);else if(j==="i")H.setChatVisible(!0),H.setFocus("composer")},{isActive:H.focus==="main"}),d(e,{flexDirection:"column",width:G,height:U,paddingLeft:1,children:[d(e,{height:1,children:[d(f,{bold:!0,children:[A," "]}),R(X0Q,{labels:Q,index:B})]}),R(e,{height:1}),D?R(zE,{rows:Math.min(8,O),width:Math.min(60,G-4),label:`Loading ${A.toLowerCase()}`}):J?R(f,{color:L.danger,wrap:"wrap",children:CQ(J)}):R(L4,{lines:I,offset:X,height:O})]})}function gNA(A,Q,B,E,I){let D=A.filter((H)=>H.currency===B).map((H)=>({name:H.name??(H.categoryId?Q.get(H.categoryId)??"Other":"Uncategorized"),value:Math.abs(cM(H[I]??H.amountMinor))})).filter((H)=>H.value>0).sort((H,X)=>X.value-H.value).slice(0,12),J=D[0]?.value??0,G=Math.min(26,Math.max(10,Math.floor(E*0.3))),U=16,Y=Math.max(4,E-G-16-4);return D.map((H)=>[...R8(WD([{text:H.name}],G),G),{text:" "},...R8([{text:Pu(H.value,J,Y),color:L.accent}],Y),{text:aQ(String(H.value),B).padStart(16),color:L.muted}])}function TNA({width:A,height:Q}){let B=FB(),E=tE.useMemo(()=>RNA(),[]),[I,D]=tE.useState(1),J=E[I],G=VG(B.store,"reports.summary",{from:J.from,to:J.to}),U=ZG(),Y=tE.useMemo(()=>{let H=G.data;if(!H)return[];let X=A-4,N=[[{text:`${J.from} to ${J.to}`,color:L.muted}]];for(let F of H.totals??[]){let V=cM(F.incomeMinor),O=cM(F.expenseMinor),j=U3A({currency:F.currency,incomeMinor:F.incomeMinor??"0",incomeRefundMinor:F.incomeRefundMinor??"0",expenseMinor:F.expenseMinor??"0",expenseRefundMinor:F.expenseRefundMinor??"0"}).result,b=`${j.kind==="loss"?"-":""}${j.amountMinor}`;N.push(...wB(F.currency,X),[{text:"Money in ",color:L.muted},{text:aQ(String(V),F.currency),color:L.success}],[{text:"Money out ",color:L.muted},{text:aQ(String(O),F.currency)}],[{text:"Net ",color:L.muted},{text:aQ(b,F.currency),bold:!0,color:j.kind==="loss"?L.danger:L.success}],[{text:"Sales tax ",color:L.muted},{text:aQ(F.taxMinor??"0",F.currency)}],[{text:"Records ",color:L.muted},{text:`${F.count}`},{text:F.provisional?` (${F.provisional} not final yet)`:"",color:L.warning}]);let x=gNA((H.categories??[]).filter((v)=>!v.outsideProfitAndLoss),B.categories,F.currency,X,"expenseMinor");if(x.length)N.push([],[{text:"Spending by category",bold:!0}],...x)}let z=[];if(H.unresolvedEntryCount)z.push([{text:`${hA.bullet} ${H.unresolvedEntryCount} transactions still need you`,color:L.warning}]);if(H.unmatchedTransactionCount)z.push([{text:`${hA.bullet} ${H.unmatchedTransactionCount} bank lines aren't matched yet`,color:L.warning}]);if(H.taxUnknownCount)z.push([{text:`${hA.bullet} ${H.taxUnknownCount} with sales tax to confirm`,color:L.warning}]);if(z.length)N.push(...wB("Before these numbers are final",X),...z);if(!(H.totals??[]).length)N.push([],...eQ([{text:"Nothing was booked in this period.",color:L.muted}],X));return N},[G.data,A,J,B.categories,U]);return R(Su,{title:"Reports",tabs:E.map((H)=>H.label),tab:I,onTab:D,lines:Y,loading:G.loading,error:G.error,width:A,height:Q,hints:"[ ] period · ↑↓ scroll · i ask AI · o browser · R refresh"})}function PNA({width:A,height:Q}){let B=FB(),E=tE.useMemo(()=>RNA(),[]),[I,D]=tE.useState(3),J=E[I],G=VG(B.store,"insights.finance.get",{from:J.from,to:J.to}),U=ZG(),Y=tE.useMemo(()=>{let H=G.data;if(!H)return[];let X=A-4,N=[],z=H.coverage;if(z){let F=z.entries?Math.round(z.reviewed/z.entries*100):100;N.push([{text:"Books done ",color:L.muted},{text:Pu(F,100,20).padEnd(20,"·"),color:F===100?L.success:L.accent},{text:` ${F}%`,bold:!0},{text:` ${z.unresolvedEntries} open · ${z.unmatchedBankTransactions} unmatched bank lines`,color:L.muted}])}for(let F of H.currencies??[]){let V=cM(F.profitMinor);N.push(...wB(F.currency,X),[{text:"Revenue ",color:L.muted},{text:aQ(F.netRevenueMinor??"0",F.currency),color:L.success}],[{text:"Expenses ",color:L.muted},{text:aQ(F.netExpenseMinor??"0",F.currency)}],[{text:"Profit ",color:L.muted},{text:aQ(String(V),F.currency),bold:!0,color:V>=0?L.success:L.danger}]);let O=gNA((F.categories??[]).map((j)=>({...j,currency:F.currency})),B.categories,F.currency,X,"expenseMinor");if(O.length)N.push([],[{text:"Where the money went",bold:!0}],...O)}if(!(H.currencies??[]).length)N.push([],[{text:"Nothing booked in this period yet.",color:L.muted}]);return N},[G.data,A,B.categories,U]);return R(Su,{title:"Insights",tabs:E.map((H)=>H.label),tab:I,onTab:D,lines:Y,loading:G.loading,error:G.error,width:A,height:Q,hints:"[ ] period · ↑↓ scroll · i ask AI · o browser · R refresh"})}function SNA({width:A,height:Q}){let B=FB(),[E,I]=tE.useState(B.route.params.get("kind")==="gst_hst"?1:0),D=VG(B.store,"tax.prep.overview",{kind:Tu[E].kind,summary:!0}),J=ZG(),G=tE.useMemo(()=>{let U=D.data;if(!U)return[];let Y=A-4,H=U.progress??{done:0,total:0},X=[[{text:U.label??Tu[E].label,bold:!0},{text:U.period?` ${U.period.from} to ${U.period.to}`:"",color:L.muted}],[{text:Pu(H.done,Math.max(1,H.total),24).padEnd(24,"·"),color:L.accent},{text:` ${H.done} of ${H.total} steps done`,color:L.muted}],[]];for(let N of U.steps??[]){let z=N.status==="done"?{text:`${hA.done} `,color:L.success}:N.status==="blocked"?{text:"■ ",color:L.danger}:N.status==="not_needed"?{text:"– ",color:L.faint}:{text:`${hA.pending} `,color:L.warning};if(X.push(...eQ([{text:N.title,color:N.status==="not_needed"?L.faint:L.text,bold:N.status==="todo"},{text:N.count?` ${N.count}`:"",color:L.warning}],Y,[z])),N.summary&&N.status!=="done")X.push(...eQ([{text:N.summary,color:L.muted}],Y,[{text:" "}]).slice(0,2))}if(U.next?.title)X.push([],[{text:`${hA.arrow} Next: `,color:L.accent},{text:U.next.title,bold:!0}]);return X.push([],...eQ([{text:"Ask AI to walk you through a step, or press o to open it in the browser.",color:L.faint}],Y)),X},[D.data,A,E,J]);return R(Su,{title:"Tax preparation",tabs:Tu.map((U)=>U.label),tab:E,onTab:I,lines:G,loading:D.loading,error:D.error,width:A,height:Q,hints:"[ ] return · ↑↓ scroll · i ask AI · o browser"})}var tE,cM=(A)=>typeof A==="string"?Number(A):typeof A==="number"?A:0,Tu;var wNA=W(async()=>{Y3A();d1();wQ();BE();E2();NG();bB();HQ();await $0([dB(),FG(),g8(),$2()]);tE=pA(JQ(),1);Tu=[{label:"Corporate tax (T2)",kind:"corporate"},{label:"GST/HST",kind:"gst_hst"}]});function Z0Q(A=new Date){let Q=A.getHours();return Q<5?"Working late":Q<12?"Good morning":Q<18?"Good afternoon":"Good evening"}function N0Q(A){let B=(A?.split("@")[0]??"").split(/[._+-]/)[0];return B?B[0].toUpperCase()+B.slice(1):""}function vNA({width:A,height:Q}){let B=FB(),E=O$.useMemo(()=>VZA(B.role,B.identity.userId),[B.role,B.identity.userId]),I=O$.useMemo(()=>E.flatMap((v)=>v.reads.map((w)=>({action:w.action,input:{...w.input}}))),[E]),J=K3A(B.store,I).map((v)=>v.data!==void 0?{status:v.stale?"stale":"ready",data:v.data}:v.error?{status:"failed"}:{status:"loading"}),G=_ZA(E,J),U=KM("/",B.role),Y=["admin","finance","contributor"].includes(B.role),H=[...Y?[{key:"add-receipt",label:"Add a receipt",detail:"A PDF, photo or saved email from this computer",verb:"Add",run:()=>{B.addReceipts()}}]:[],...G.items.map((v)=>({key:v.id,label:v.label,detail:v.detail,verb:v.verb,run:()=>B.navigate(v.href,{focus:"main"})})),...U.map((v)=>({key:`ask:${v}`,label:v,run:()=>B.ask(v)}))],X=Y?1:0,[N,z]=O$.useState(0),F=Math.min(N,Math.max(0,H.length-1)),{setHints:V}=B;O$.useEffect(()=>{V("↑↓ move · ⏎ open · Tab message box · ⌃K jump · ? keys")},[V]),iQ((v,w)=>{if(w.downArrow||v==="j")z((k)=>Math.min(H.length-1,k+1));else if(w.upArrow||v==="k")z((k)=>Math.max(0,k-1));else if(w.return||w.rightArrow)H[F]?.run();else if(w.escape||w.leftArrow)B.setFocus(B.layout.sidebarWidth?"sidebar":"composer");else if(v==="R")B.store.invalidate()},{isActive:B.focus==="main"});let O=N0Q(B.identity.email),j=Q>=24&&A>=pU[0].length+4,b=B.focus==="main",x=(v,w,k=!1)=>{let h=b&&w===F,t=v.verb?`${v.verb} ${hA.arrow}`:"",i=Math.max(8,A-2-(t?eB(t)+2:0));return d(e,{flexDirection:"column",flexShrink:0,children:[d(e,{width:A-2,height:1,children:[R(e,{width:i,flexShrink:0,children:d(f,{color:h?L.focus:L.text,bold:h,wrap:"truncate-end",children:[h?hA.pointer:" "," ",k?d(f,{color:L.accent,children:[hA.ai," "]}):null,v.label]})}),t?R(e,{flexGrow:1,justifyContent:"flex-end",children:R(f,{color:h?L.focus:L.faint,wrap:"truncate-start",children:t})}):null]}),v.detail&&!k?R(e,{height:1,children:d(f,{color:L.muted,wrap:"truncate-end",children:[" ",v.detail]})}):null]},v.key)};return d(e,{flexDirection:"column",width:A,height:Q,paddingX:1,overflow:"hidden",children:[j?R(e,{flexDirection:"column",marginBottom:1,flexShrink:0,children:pU.map((v,w)=>R(oh,{text:v,width:[...pU[0]].length},w))}):null,d(e,{flexDirection:"column",flexShrink:0,children:[d(f,{bold:!0,wrap:"truncate-end",children:[Z0Q(),O?`, ${O}`:"","."]}),R(f,{color:L.muted,wrap:"truncate-end",children:`Here's what needs you at ${B.identity.organizationName??"your company"}.`})]}),Y?R(e,{marginTop:1,flexDirection:"column",flexShrink:0,children:x(H[0],0)}):null,d(e,{marginTop:1,flexDirection:"column",flexShrink:0,children:[R(f,{color:L.faint,bold:!0,children:"NEEDS YOU"}),G.items.map((v,w)=>x(H[X+w],X+w)),G.loading.length?R(zE,{rows:Math.min(3,G.loading.length),width:Math.min(60,A-4),label:"Checking what needs you"}):null,!G.loading.length&&!G.items.length?R(f,{color:L.success,children:`${hA.done} You're all caught up.`}):null,G.unavailable.length?R(f,{color:L.faint,wrap:"truncate-end",children:`Couldn't check: ${G.unavailable.join(", ")}`}):null]}),d(e,{marginTop:1,flexDirection:"column",flexShrink:0,children:[R(f,{color:L.faint,bold:!0,children:"TRY ASKING"}),U.map((v,w)=>x(H[X+G.items.length+w],X+G.items.length+w,!0))]})]})}var O$;var bNA=W(async()=>{mU();L8();ah();BE();E2();bB();uC();HQ();await $0([dB(),FG(),tH()]);O$=pA(JQ(),1)});import{readFile as z0Q,stat as q0Q}from"node:fs/promises";import{homedir as F0Q}from"node:os";import{basename as M0Q,resolve as V0Q}from"node:path";function _0Q(A,Q){let B=(A.length-1)*2+2,E=A.reduce((G,U)=>G+(U.width==="flex"?0:U.width),0),I=A.filter((G)=>G.width==="flex").length||1,D=Q-B;if(E+I*12<=D)return A.map((G)=>G.width==="flex"?Math.floor((D-E)/I):G.width);let J=Math.max(0.3,(D-I*12)/Math.max(1,E));return A.map((G)=>G.width==="flex"?12:Math.max(4,Math.floor(G.width*J)))}function O0Q(A,Q){let B=[...A],E=(I)=>I.reduce((D,J)=>D+(J.width==="flex"?14:J.width),0)+(I.length-1)*2+2;while(E(B)>Q){let I=B.map((D)=>!!D.optional).lastIndexOf(!0);if(I<0)break;B=B.filter((D,J)=>J!==I)}return{columns:B,widths:_0Q(B,Q)}}function L0Q(A,Q,B,E,I,D,J=!1){let G=[{text:I?`${hA.pointer} `:J?"› ":" ",color:I?L.focus:L.faint}];return Q.forEach((U,Y)=>{let H=U.cell(A,E),X=WD([H],B[Y]),N=U.align==="right"?[{text:" ".repeat(Math.max(0,B[Y]-X.reduce((z,F)=>z+[...F.text].length,0)))},...X]:R8(X,B[Y]);if(G.push(...N),Y<Q.length-1)G.push({text:" "})}),I?R8(G.map((U)=>({...U,backgroundColor:L.selectionBg})),D,{backgroundColor:L.selectionBg}):G}function W0Q(A,Q){return ME(Object.entries(A).filter(([,B])=>["string","number","boolean"].includes(typeof B)).slice(0,30).map(([B,E])=>[B.replace(/_/g," "),String(E)]),Q)}function j0Q(A,Q){let B=A.views.findIndex((I)=>I.href===Q.href&&Object.keys(I.input).length>0);if(B>=0)return B;let E=Q.params.get("status");if(A.key==="transactions"&&E)return Math.max(0,A.views.findIndex((I)=>I.href.endsWith(`status=${E}`)));if(Q.params.get("mailStatus")==="quarantined")return Math.max(0,A.views.findIndex((I)=>I.input.status==="quarantined"));return 0}async function R0Q(A){let Q=V0Q(A.trim().replace(/^~(?=$|\/)/,F0Q()).replace(/^["']|["']$/g,"")),B=await q0Q(Q).catch(()=>null);if(!B?.isFile())throw Error(`There's no file at ${Q}.`);if(B.size>2097152)throw Error("That file is over 2 MB. Upload it in the browser instead (press o).");let E=jNA(Q);if(!E)throw Error("Use a PDF, a photo (JPG, PNG, HEIC, WebP) or an .eml email.");return{filename:M0Q(Q),mimeType:E,contentBase64:(await z0Q(Q)).toString("base64")}}function lM({spec:A,route:Q,recordId:B,width:E,height:I}){let D=FB(),[J,G]=yB.useState(()=>j0Q(A,Q)),[U,Y]=yB.useState(Q.params.get("q")??""),[H,X]=yB.useState(null),[N,z]=yB.useState(0),[F,V]=yB.useState(!1),[O,j]=yB.useState(0),[b,x]=yB.useState({rows:[],done:!1}),[v,w]=yB.useState(!1),[k,h]=yB.useState(new Map),[t,i]=yB.useState(null),UA=A.views[Math.min(J,A.views.length-1)],CA=yB.useMemo(()=>({role:D.role,categories:D.categories}),[D.role,D.categories]),GA=yB.useMemo(()=>({...UA.input,...U&&A.searchParam?{[A.searchParam]:U}:{}}),[UA,U,A.searchParam]),iA=yB.useMemo(()=>A.paging==="offset"?{...GA,limit:A.pageSize+(A.probe?1:0),offset:0}:A.paging==="cursor"?{...GA,limit:A.pageSize}:GA,[GA,A]),jA=VG(D.store,A.action,iA),IQ=yB.useMemo(()=>jA.data===void 0?null:A.read(jA.data,A.pageSize),[jA.data,A]),[_A,RB]=yB.useState(jA.data);if(_A!==jA.data)RB(jA.data),x({rows:[],done:!1}),h(new Map);let YA=yB.useMemo(()=>[...IQ?.rows??[],...b.rows],[IQ,b.rows]),yA=!!B&&!!IQ&&!YA.some((gA)=>A.rowId(gA)===B),YQ=VG(D.store,A.detail?.action??"",yA&&A.detail?.row?A.detail.input({id:B,contractorId:B,key:B}):null),yQ=yA&&YQ.data!==void 0?A.detail?.row?.(YQ.data)??null:null,zQ=yB.useMemo(()=>{return(yQ?[yQ,...YA]:YA).map((p)=>{let IA=k.get(A.rowId(p));return IA?{...p,...IA}:p})},[YA,yQ,k,A]),[uA,sA]=yB.useState(null);if(B&&uA!==B&&zQ.length){let gA=zQ.findIndex((p)=>A.rowId(p)===B);if(gA>=0)sA(B),z(gA),V(!0)}let qQ=IQ?.total,YB=!b.done&&!!IQ&&(A.paging==="cursor"?b.rows.length?!!b.nextCursor:!!IQ.nextCursor:A.paging==="offset"&&(typeof qQ==="number"?zQ.length<qQ:b.rows.length?!b.done:IQ.hasMore)),tA=zQ[Math.min(N,zQ.length-1)],WQ=yB.useCallback(()=>{if(!YB||v||!IQ)return;w(!0);let gA=A.paging==="cursor"?{...GA,limit:A.pageSize,cursor:b.rows.length?b.nextCursor:IQ.nextCursor}:{...GA,limit:A.pageSize+(A.probe?1:0),offset:zQ.length};D.store.load(A.action,gA).then((p)=>{let IA=A.read(p,A.pageSize);x((SA)=>({rows:[...SA.rows,...IA.rows],nextCursor:IA.nextCursor,done:A.paging==="cursor"?!IA.nextCursor:typeof IA.total==="number"?zQ.length+IA.rows.length>=IA.total:!IA.hasMore}))},(p)=>D.toast(CQ(p),"danger")).finally(()=>w(!1))},[YB,v,IQ,A,GA,b,zQ.length,D]),EQ=(gA)=>{let p=Math.max(0,Math.min(zQ.length-1,gA));if(z(p),p>=zQ.length-8)WQ()},AB=tA&&A.detail?A.detail.input(tA):null,fB=AB?JSON.stringify(AB):"",B0=A.detail?.action??"",{store:i0,setFocusRecord:rQ,setHints:hB}=D;yB.useEffect(()=>{if(!fB||!B0)return;let gA=setTimeout(()=>i0.prefetch(B0,JSON.parse(fB)),150);return()=>clearTimeout(gA)},[fB,B0,i0]);let MB=VG(D.store,B0,F&&AB?AB:null),KB=tA&&A.rowHref?A.rowHref(tA):null,X0=tA?A.rowTitle(tA):"";yB.useEffect(()=>{rQ(F&&KB?{href:KB,label:X0}:null)},[F,KB,X0,rQ]),yB.useEffect(()=>()=>rQ(null),[rQ]);let v0=yB.useCallback((gA)=>({write:async(p,IA)=>{let SA=await D.api.call(p,IA,{idempotencyKey:bI()});return D.store.invalidate(),SA},read:(p,IA)=>D.store.load(p,IA,{force:!0}),prompt:D.dialogs.prompt,choose:D.dialogs.choose,confirm:D.dialogs.confirm,showSecret:D.dialogs.showSecret,patch:(p)=>{if(!gA)return()=>{return};let IA=A.rowId(gA),SA;return h((mA)=>{SA=mA.get(IA);let TA=new Map(mA);return TA.set(IA,{...SA,...p}),TA}),()=>h((mA)=>{let TA=new Map(mA);if(SA)TA.set(IA,SA);else TA.delete(IA);return TA})},toast:D.toast,categories:async()=>{return(await D.store.load("categories.list",{})).filter((IA)=>IA.active).map((IA)=>({id:IA.id,path:IA.path??IA.name})).sort((IA,SA)=>IA.path.localeCompare(SA.path))},readFile:R0Q}),[D,A]),nB=(gA,p)=>{i(gA),p().catch((IA)=>{let SA=CQ(IA);D.toast(IA instanceof mQ&&IA.dashboardUrl?`${SA} A person does this in Oatmilk — press o to open it.`:SA,"danger")}).finally(()=>i(null))},j0=(A.rowActions??[]).filter((gA)=>tA&&(!gA.when||gA.when(tA,D.role))),SQ=(A.listActions??[]).filter((gA)=>!gA.when||gA.when(D.role)),gB=F&&E>=96,h0=gB?Math.floor(E*0.55):E,LI=gB?E-h0-1:E,Z0=Math.max(3,I-3),cI=ZG(),G0=yB.useMemo(()=>{if(!F||!tA)return[];let gA=LI-3,p=A.detail?A.detail.lines(MB.data??{},tA,gA,CA):W0Q(tA,gA);return MB.error?[...p,[],...eQ([{text:CQ(MB.error),color:L.danger}],gA)]:p},[F,tA,MB.data,MB.error,LI,CA,A,cI]),KI=[F?"Esc close":"⏎ open",A.searchParam?"/ search":"",A.views.length>1?"[ ] views":"",...j0.map((gA)=>`${gA.key} ${gA.label.toLowerCase()}`),...SQ.map((gA)=>`${gA.key} ${gA.label.toLowerCase()}`),"i ask AI","o browser","? keys"].filter(Boolean).join(" · ");yB.useEffect(()=>{hB(KI)},[KI,hB]),iQ((gA,p)=>{if(H){if(p.escape){X(null);return}let mA=BI(H,gA,p,200);if(mA.type==="submit")Y(H.value.trim()),X(null),z(0),j(0);else if(mA.type==="edit")X(mA.state);return}if(t)return;let IA=Math.max(1,Z0-2),SA=/^(j+|k+)$/.test(gA)?gA.length:1;if(p.downArrow||/^j+$/.test(gA))EQ(N+SA);else if(p.upArrow||/^k+$/.test(gA))EQ(N-SA);else if(p.pageDown)if(F&&!gB)j((mA)=>mA+IA);else EQ(N+IA);else if(p.pageUp)if(F&&!gB)j((mA)=>Math.max(0,mA-IA));else EQ(N-IA);else if(gA==="J")j((mA)=>mA+3);else if(gA==="K")j((mA)=>Math.max(0,mA-3));else if(p.home||gA==="g")EQ(0);else if(p.end||gA==="G")EQ(zQ.length-1);else if(p.return||p.rightArrow||gA==="l"){if(tA)V(!0),j(0)}else if(p.escape||p.leftArrow||gA==="h")if(F)V(!1);else D.setFocus(D.layout.sidebarWidth?"sidebar":"composer");else if(gA==="/"&&A.searchParam)X({value:U,cursor:U.length});else if((gA==="]"||gA==="[")&&A.views.length>1)G((mA)=>(mA+(gA==="]"?1:A.views.length-1))%A.views.length),z(0),j(0);else if(gA==="R"||p.ctrl&&gA==="r")D.store.invalidate(),jA.refresh();else if(gA==="o")D.openInBrowser(KB??UA.href);else if(gA==="y")D.copy(`${D.session.host}${KB??UA.href}`,"Link");else if(gA==="i"){if(tA&&KB)V(!0),D.setFocusRecord({href:KB,label:A.rowTitle(tA)});D.setChatVisible(!0),D.setFocus("composer")}else{let mA=j0.find((eA)=>eA.key===gA);if(mA&&tA){nB(mA.label,()=>mA.run(tA,v0(tA)));return}let TA=SQ.find((eA)=>eA.key===gA);if(TA)nB(TA.label,()=>TA.run(v0(null)))}},{isActive:D.focus==="main"});let{columns:n0,widths:bA}=O0Q(A.columns,h0-2),BA=Math.max(1,Z0-1),XA=Math.max(0,Math.min(N-Math.floor(BA/2),zQ.length-BA)),$Q=A.views.length>1?A.views.flatMap((gA,p)=>[{text:p===J?` ${gA.label} `:` ${gA.label} `,color:p===J?L.text:L.muted,bold:p===J,underline:p===J},{text:" "}]):[],kQ=IQ?`${zQ.length?`${Math.min(N+1,zQ.length)} of ${typeof qQ==="number"?qQ:`${zQ.length}${YB?"+":""}`}`:""}`:"";return d(e,{flexDirection:"column",width:E,height:I,children:[d(e,{justifyContent:"space-between",height:1,paddingLeft:1,children:[d(e,{children:[d(f,{bold:!0,children:[A.title," "]}),R(O4,{line:$Q})]}),d(e,{gap:1,flexShrink:0,children:[t?R(f0,{label:`${t}…`}):jA.refreshing||v?R(f0,{}):null,H?R(e,{width:Math.min(34,Math.floor(E/3)),children:R(p0,{state:H,width:Math.min(34,Math.floor(E/3)),placeholder:"Search…",prefix:[{text:"/ ",color:L.accent}]})}):U?d(f,{color:L.accent,children:["/",U," ",R(f,{color:L.faint,children:"(/ to change)"})]}):null,R(f,{color:L.faint,children:kQ})]})]}),R(e,{height:1,paddingLeft:1,width:h0,children:!gB&&F?null:R(O4,{line:WD([{text:" "},...n0.flatMap((gA,p)=>[{text:gA.align==="right"?gA.label.padStart(bA[p]):gA.label.padEnd(bA[p]),color:L.faint},{text:p<n0.length-1?" ":""}])],h0-2)})}),d(e,{flexDirection:"row",height:Z0,children:[!gB&&F?null:d(e,{flexDirection:"column",width:h0,height:Z0,paddingLeft:1,children:[jA.loading?R(zE,{rows:Math.min(BA,10),width:h0-2,columns:bA,label:`Loading ${A.title.toLowerCase()}`}):jA.error?d(e,{flexDirection:"column",children:[R(f,{color:L.danger,wrap:"wrap",children:jA.error instanceof mQ&&jA.error.status===403?`You can't open ${A.title.toLowerCase()} with ${D.session.kind==="api_key"?"this API key":"your role"}: ${jA.error.message}`:CQ(jA.error)}),R(f,{color:L.faint,children:"R to try again · o open in the browser"})]}):!zQ.length?R(f,{color:L.muted,wrap:"wrap",children:U?`Nothing matches "${U}".`:A.empty}):zQ.slice(XA,XA+BA).map((gA,p)=>R(O4,{line:L0Q(gA,n0,bA,CA,XA+p===N&&D.focus==="main",h0-2,XA+p===N)},A.rowId(gA))),v?R(f,{color:L.faint,children:" Loading more…"}):null]}),F&&tA?d(e,{flexDirection:"column",width:LI,height:Z0,borderStyle:"single",borderTop:!1,borderBottom:!1,borderRight:!1,borderLeft:gB,borderColor:L.border,paddingLeft:gB?1:1,children:[R(L4,{lines:G0,offset:Math.min(O,Math.max(0,G0.length-3)),height:Math.max(1,Z0-(MB.loading?3:1))}),MB.loading?R(zE,{rows:2,width:Math.min(40,LI-4),label:"Loading details"}):null,j0.length?R(f,{color:L.faint,wrap:"truncate-end",children:j0.map((gA)=>`${gA.key} ${gA.label}`).join(" · ")}):null]}):null]})]})}var yB;var wu=W(async()=>{SE();wQ();RD();BE();E2();bB();NG();HQ();await $0([dB(),gD(),FG(),vD(),g8(),$2()]);yB=pA(JQ(),1)});function kNA(A,Q="corporate"){return A==="close"&&Q==="gst_hst"?"Lock the period":vu[A]}var vu;var xNA=W(()=>{vu={accountant:"What your accountant needs",company:"Your company details",bank:"Add your bank records",statements:"Bank and card statements",review:"Check your records",records:"Check your records",tax_records:"Check the sales tax",close:"Lock the year",questions:"A few quick questions",personal:"Paid with your own money",prizes:"Prizes you paid out",gifi:"Match categories to the tax form",handoff:"Send it to your accountant",adjustments:"Anything else that changes your tax?",return:"Your GST/HST numbers"}});var yNA;var fNA=W(()=>{yNA=[{id:"overview",label:"Overview",href:"/accountant"},{id:"year-end",label:"Year-end",href:"/accountant/year-end"},{id:"financial-statements",label:"Financial statements",href:"/accountant/financial-statements"},{id:"reports",label:"Downloads",href:"/accountant/reports"},{id:"transactions",label:"Transactions",href:"/accountant/transactions"},{id:"receipts",label:"Receipts",href:"/accountant/receipts"},{id:"statements",label:"Bank statements",href:"/accountant/statements"},{id:"map",label:"Map",href:"/accountant/map?view=map"},{id:"access",label:"Access",href:"/accountant/access"}]});function S0Q(A,Q,B,E){let I=A.label,D={label:A.label,description:g0Q[A.id],href:A.href,group:I},J=E1(A.id,Q,B,E),G=J?J.groups.flatMap((U)=>U.links.map((Y)=>({label:Y.label,href:Y.href,group:U.label?`${I} › ${U.label}`:I}))):A.children.map((U)=>({label:U.label,href:U.href,group:I}));return[D,...G.filter((U)=>U.href!==A.href).map((U)=>({...U,description:T0Q[U.href]??`${U.label} in ${U.group}.`}))]}function bu(A,Q=!1,B="company"){if(A==="accountant")return yNA.map((I)=>({label:I.label,href:I.href,group:I.label,description:I.id==="access"?"Your access level, end date and requests for more time or permission.":`${I.label} for the company whose books you have open.`})).concat([{label:"Switch company",href:"/accountant/companies",group:"Accountant",description:"Choose another client whose books you can open."}]);let E=new Map;for(let I of q$(A,Q,B))for(let D of S0Q(I,A,Q,B)){let J=OD(D.href);if(J&&!E.has(J))E.set(J,{...D,href:J})}for(let I of aH(A,B)){let D=OD(`/settings?section=${I.id}`);if(D&&!E.has(D))E.set(D,{label:I.title,description:`${I.title} in Settings.`,href:D,group:"Settings"})}for(let I of P0Q)if(I.roles.includes(A)&&!E.has(I.href))E.set(I.href,{label:I.label,description:I.description,href:I.href,group:I.group});return[...E.values()]}function b0Q(A){if(A.pathname!=="/finance/tax"||A.searchParams.has("view"))return null;let Q=A.searchParams.get("step");if(!Q||!Object.hasOwn(vu,Q))return null;return kNA(Q,A.searchParams.get("kind")==="gst_hst"?"gst_hst":"corporate")}function hNA(A,Q){if(vH(A)?.destination==="/accountant/map")return"Accountant workspace · Map";let B=new URL(A,"https://oatmilk.invalid");if(Q==="accountant"){let G=bu(Q).find((Y)=>new URL(Y.href,"https://oatmilk.invalid").pathname===B.pathname)?.label??"Accountant workspace",U=B.searchParams.has("entry")?"transaction":B.searchParams.has("receipt")?"receipt":null;return U?`${G} › ${U}`:G}let E=uU(B.pathname),I=b0Q(B);if(I)return`${VM(E)} · ${I}`;let D=B.pathname===FZA?"Agreement writer":_M({view:E,search:B.searchParams,role:Q})||VM(E);if((E==="checklist"||E==="calendar")&&B.searchParams.has("item"))return`${D} › checklist item`;let J=w0Q.find(([G])=>v0Q.test(B.searchParams.get(G)??"")||G!=="template"&&B.searchParams.has(G));return J?`${D} › ${J[1]}`:D}var g0Q,T0Q,P0Q,w0Q,v0Q;var uNA=W(()=>{mU();nh();xNA();l1();Eh();fNA();g0Q={home:"What needs you today, what Autopilot is doing, and receipts missing for your own cards.",inbox:"Receipts, invoices and company email that came in, uploads, quarantined mail and connected inboxes.",checklist:"Compliance and month-end tasks with their deadlines: what's overdue, due in the next 30 days and later, the one to do next, and what was done recently.",calendar:"The checklist's deadlines with invoice due dates, agreement dates and contractor pay runs, month by month.",ai:"Autopilot: its jobs, the agents and their status, classifiers, what Oatmilk remembers, and connections for AI apps.",financeAi:"Finance AI: ask about or get help with anything in finance: transactions, receipts, matching, Stripe, invoices, reimbursements, subscriptions, budgets, reserves, reports for the accountant and taxes.",peopleAi:"People AI: ask about or get help with contractors and recruiting: the directory, timesheets, payouts, agreements, tax slips, job postings and interviews.",legalAi:"Legal AI: ask about or get help with agreements: what's waiting on signatures, contractor agreements, templates and writing a new agreement.",insightsAi:"Insights AI: ask how the company is doing: spending and income trends, the forecast, people, projects, tax and the map.",compliance:"Compliance research and the regulation library.",chiefOfStaff:"The Chief of Staff, the Oatmilk agent in Discord: whether it's on, its rules for each Discord server and channel, rules for people and roles, the tools it may use, its scheduled posts and its activity.",logs:"Every run and background job Oatmilk recorded, with its steps and errors.",history:"Everything anyone changed in the company, people, Ask AI, AI apps, the API and automation, with the values before and after and a way to roll changes back.",developers:"The developer portal: API keys, webhooks, API usage and analytics, the request log of every API and MCP request, connecting AI apps, and the developer docs.",settings:"Company, categories, invoices, reminders, people, accountant access, bank connections, email, AI keys and data connectors.",godMode:"Platform administrators only: sign-ups waiting for approval and every workspace's activity and AI spend, as aggregate numbers.",transactions:"Every bank and card transaction with its category, receipt, project and status; projects, merchants, trips, accounts and statements.",reconcile:"Matching receipts to bank lines, Stripe payouts and bank transactions.",invoices:"Invoices to customers: what needs action, unpaid, overdue, paid, drafts, scheduled and recurring invoices, payment plans, written off, cancelled and archived invoices, their projects, and customers and vendors.",tax:"The year-end tax preparation checklist and the tax records kept after filing.",taxInfo:"Tax info: the company's tax due dates (GST/HST returns and payments, the T2 and its balance, instalments, slips and the annual return), its GST/HST registration (number, registration date, filing frequency, year-end and method), corporate income tax details (business number, fiscal year-end, when tax owing is due) and other registrations, and the company's names, numbers, incorporation date and place. Administrators change them here and add many company and tax documents at once; Oatmilk reads them and shows what it found to check before saving.",reports:"A summary of money in and out, and exports of the records and receipts, for any period.",financialStatements:"The balance sheet, income statement, trial balance, general ledger, GST/HST, Stripe and contractors for any fiscal year or dates, to pick and download as Excel or PDF, and Send to accountant: one ZIP of everything emailed to the accountant.",insights:"Trends in spending, income, people, projects and tax, and a searchable world map of transactions, trips, stays, venues and events.",reimbursements:"Purchases people paid for themselves and paying them back.",subscriptions:"Software subscriptions found in the company's spending, with renewals and owners.",budgets:"Spending budgets, tax and accountant costs, money set aside in bank accounts, funding gaps, filing dates and payment deadlines.",documents:"Agreements sent for signature, contractor agreements and templates.",people:"Recruiting: job postings, candidates, interviews and the public job board.",contractors:"Contractors, their roles and rates, timesheets, payouts and tax slips."},T0Q={"/finance/tax":"The guided year-end checklist for the T2 or a GST/HST period: the steps, what each needs and the year-end package for the accountant.","/finance/tax?view=stripe":"Stripe for one fiscal year: charges before fees, Stripe's fees, refunds, disputes and payouts by month, as a ZIP, Excel or PDF.","/finance/tax?view=gst-hst":"File the GST/HST (HST) return yourself, step by step: check the lines, enter them on the CRA's site and pay.","/finance/tax?view=slips":"File contractor T4A and T4A-NR slips yourself, step by step, including contractors outside Canada.","/finance/tax?view=t2":"File the T2 corporate income tax return yourself, step by step: pay the balance, gather the statements, Schedule 50 and certified software.","/finance/tax?view=shareholders":"The shareholder register: who owns which class and number of shares, directors and officers, dividends and the T2 Schedule 50."},P0Q=[{label:"New invoice",description:"Write and send a new invoice.",href:"/finance/invoices/new",group:"Invoices",roles:["admin","finance"]},{label:"New agreement",description:"Send an agreement or document for e-signature.",href:"/legal/agreements/new",group:"Agreements",roles:["admin","finance"]},{label:"Write an agreement",description:"Draft a new agreement with AI help.",href:"/legal/agreements/write",group:"Agreements",roles:["admin","finance"]},{label:"Tax setup",description:"Set the fiscal year and tax details tax preparation needs.",href:"/finance/tax/setup",group:"Taxes",roles:["admin","finance"]},{label:"New API key",description:"Create a scoped, expiring API key for a script, integration or agent.",href:"/developers?view=keys&new=key",group:"Developers",roles:["admin","finance","contributor"]}];w0Q=[["entry","transaction"],["mail","email"],["invoice","invoice"],["party","customer"],["account","customer"],["contractor","contractor"],["statement","statement"],["envelope","agreement"],["template","template"],["event","change"]],v0Q=/^[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/i});function mNA({width:A,height:Q}){let B=FB(),E=B.role,I=B.route.href,D=hNA(I,E)||"This page",J=iU.useMemo(()=>bu(E).find((N)=>N.href===I||N.href===B.route.path)?.description,[E,I,B.route.path]),U=[...KM(B.route.path,E).map((N)=>({label:N,ai:!0,run:()=>B.ask(N)})),{label:`Open ${D} in the browser`,ai:!1,run:()=>B.openInBrowser(I)}],[Y,H]=iU.useState(0),{setHints:X}=B;return iU.useEffect(()=>{X("↑↓ move · ⏎ choose · Tab message box · o browser")},[X]),iQ((N,z)=>{if(z.downArrow||N==="j")H((F)=>Math.min(U.length-1,F+1));else if(z.upArrow||N==="k")H((F)=>Math.max(0,F-1));else if(z.return)U[Y]?.run();else if(N==="o")B.openInBrowser(I);else if(z.escape||z.leftArrow)B.setFocus(B.layout.sidebarWidth?"sidebar":"composer")},{isActive:B.focus==="main"}),d(e,{flexDirection:"column",width:A,height:Q,paddingX:1,children:[R(f,{bold:!0,children:D}),J?R(f,{color:L.muted,wrap:"wrap",children:J}):null,d(e,{marginTop:1,flexDirection:"column",children:[R(f,{color:L.muted,wrap:"wrap",children:"Ask AI can read and work on this page for you, with your permissions. Ask anything below, or choose:"}),R(e,{marginTop:1,flexDirection:"column",children:U.map((N,z)=>{let F=B.focus==="main"&&z===Y;return d(f,{color:F?L.focus:L.text,wrap:"truncate-end",children:[F?hA.pointer:" "," ",N.ai?d(f,{color:L.accent,children:[hA.ai," "]}):R(f,{color:L.info,children:"↗ "}),N.label]},N.label)})}),R(e,{marginTop:1,children:R(f,{color:L.faint,wrap:"truncate-middle",children:cU(B.session.host,I)})})]})]})}var iU;var cNA=W(async()=>{L8();uNA();qG();BE();bB();HQ();await dB();iU=pA(JQ(),1)});class ku{constructor(A){this._maxBufferSize=A?.maxBufferSize??k0Q}append(A){if((this._buffer?.length??0)+A.length>this._maxBufferSize)throw this.clear(),Error(`ReadBuffer exceeded maximum size of ${this._maxBufferSize} bytes`);this._buffer=this._buffer?Buffer.concat([this._buffer,A]):A}readMessage(){if(!this._buffer)return null;let A=this._buffer.indexOf(`
516
516
  `);if(A===-1)return null;let Q=this._buffer.toString("utf8",0,A).replace(/\r$/,"");return this._buffer=this._buffer.subarray(A+1),x0Q(Q)}clear(){this._buffer=void 0}}function x0Q(A){return q6.parse(JSON.parse(A))}function lNA(A){return JSON.stringify(A)+`
517
517
  `}var k0Q=10485760;var pNA=W(()=>{BC()});import dNA from"node:process";class xu{constructor(A=dNA.stdin,Q=dNA.stdout,B){this._stdin=A,this._stdout=Q,this._started=!1,this._ondata=(E)=>{try{this._readBuffer.append(E),this.processReadBuffer()}catch(I){this.onerror?.(I),this.close().catch(()=>{})}},this._onerror=(E)=>{this.onerror?.(E)},this._readBuffer=new ku({maxBufferSize:B?.maxBufferSize})}async start(){if(this._started)throw Error("StdioServerTransport already started! If using Server class, note that connect() calls start() automatically.");this._started=!0,this._stdin.on("data",this._ondata),this._stdin.on("error",this._onerror)}processReadBuffer(){while(!0)try{let A=this._readBuffer.readMessage();if(A===null)break;this.onmessage?.(A)}catch(A){this.onerror?.(A)}}async close(){if(this._stdin.off("data",this._ondata),this._stdin.off("error",this._onerror),this._stdin.listenerCount("data")===0)this._stdin.pause();this._readBuffer.clear(),this.onclose?.()}send(A){return new Promise((Q)=>{let B=lNA(A);if(this._stdout.write(B))Q();else this._stdout.once("drain",Q)})}}var iNA=W(()=>{pNA()});var nNA="oatmilk";var aNA=()=>{};var sNA={};pQ(sNA,{runMcpBridge:()=>rNA,mcpConfigText:()=>pM,mcpCommand:()=>f0Q,bridgeTransports:()=>oNA});function y0Q(A){return"id"in A&&"method"in A&&(typeof A.id==="string"||typeof A.id==="number")?A.id:null}function oNA(A,Q,B=()=>{return}){let E=new Set;return new Promise((I)=>{let D=!1,J=()=>{if(D)return;D=!0,Promise.allSettled([A.close(),Q.close()]).then(()=>I())};A.onmessage=(G)=>{let U=y0Q(G);if(U!==null&&"method"in G&&G.method==="initialize")E.add(U);Q.send(G).catch((Y)=>{if(B(`[oatmilk mcp] request failed: ${Y instanceof Error?Y.message:String(Y)}`),U!==null)A.send({jsonrpc:"2.0",id:U,error:{code:-32603,message:Y instanceof Error?Y.message:"Oatmilk's MCP server couldn't be reached."}})})},Q.onmessage=(G)=>{if("id"in G&&"result"in G&&E.delete(G.id)){let U=G.result.protocolVersion;if(typeof U==="string")Q.setProtocolVersion?.(U)}A.send(G)},A.onclose=J,Q.onclose=J,A.onerror=(G)=>B(`[oatmilk mcp] stdio: ${G.message}`),Q.onerror=(G)=>B(`[oatmilk mcp] remote: ${G.message}`)})}async function rNA(A,Q,B){let E=new VK(hw(A,Q),{fetch:fw(A)}),I=new xu,D=oNA(I,E,B?(J)=>process.stderr.write(`${J}