attio 0.0.1-experimental.20260421 → 0.0.1-experimental.20260508
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli/index.js +1 -1
- package/dist/template/eslint.attio.config.js +1 -1
- package/dist/types/client/workflow/inputs/currency.d.ts +2 -0
- package/dist/types/client/workflow/inputs/currency.d.ts.map +1 -1
- package/dist/types/client/workflow/inputs/text.d.ts +1 -0
- package/dist/types/client/workflow/inputs/text.d.ts.map +1 -1
- package/dist/types/server/connections.d.ts +4 -2
- package/dist/types/server/connections.d.ts.map +1 -1
- package/dist/types/shared/workflow/activator.d.ts +1 -1
- package/dist/types/shared/workflow/activator.d.ts.map +1 -1
- package/dist/types/shared/workflow/deactivator.d.ts +1 -1
- package/dist/types/shared/workflow/deactivator.d.ts.map +1 -1
- package/dist/types/shared/workflow/defer-callback.d.ts +20 -2
- package/dist/types/shared/workflow/defer-callback.d.ts.map +1 -1
- package/dist/types/shared/workflow/executor.d.ts +1 -1
- package/dist/types/shared/workflow/executor.d.ts.map +1 -1
- package/dist/types/tsconfig.lib.tsbuildinfo +1 -1
- package/package.json +5 -5
package/dist/cli/index.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{fileURLToPath as e}from"node:url";import{dirname as r}from"node:path";import t,{accessSync as n,constants as o,createReadStream as a,existsSync as i,promises as c,readFileSync as s}from"fs";import u,{join as l,resolve as f}from"path";import{Argument as p,Command as d,Option as h}from"commander";import{z as b}from"zod";import{combine as y,combineAsync as v,complete as m,errored as w,fromPromise as g,fromThrowable as E,isComplete as _,isErrored as O,map as k}from"@attio/fetchable";import S from"readline/promises";import I from"fs/promises";import{Project as T,SyntaxKind as x}from"ts-morph";import A from"process";import R from"chalk";import j,{createInterface as P}from"readline";import N from"typescript";import D from"node:fs";import{parse as C}from"@typescript-eslint/parser";import{analyze as F}from"@typescript-eslint/scope-manager";import{walk as L}from"zimmerframe";import{context as U}from"esbuild";import M from"tmp-promise";import G from"@fal-works/esbuild-plugin-global-externals";import{glob as B}from"glob";import V from"chokidar";import{Kind as W,OperationTypeNode as J,buildSchema as Y,isExecutableDefinitionNode as K,parse as H}from"graphql";import{codegen as q}from"@graphql-codegen/core";import{format as $}from"prettier";import{codeFrameColumns as X}from"@babel/code-frame";import z from"node-notifier";import{createHash as Q,randomBytes as Z}from"crypto";import{serve as ee}from"@hono/node-server";import{Hono as er}from"hono";import et from"open";import en from"net";import eo from"stdin-blocker";import ea from"tiny-cursor";import{select as ei}from"@inquirer/prompts";import{findUpSync as ec}from"find-up-simple";import es from"dotenv";import{graphqlServer as eu}from"@hono/graphql-server";import el from"boxen";import ef from"node:readline/promises";import ep from"ably";import ed from"cli-table3";import{format as eh}from"date-fns";import*as eb from"@graphql-codegen/typescript-operations";var ey,ev,em,ew={},eg={};function eE(e){var r=eg[e];if(void 0!==r)return r.exports;var t=eg[e]={exports:{}};return ew[e](t,t.exports,eE),t.exports}eE.m=ew,eE.f={},eE.e=e=>Promise.all(Object.keys(eE.f).reduce((r,t)=>(eE.f[t](e,r),r),[])),eE.u=e=>""+e+".index.js",eE.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),eE.p="",eE.rv=()=>"1.5.2",ey={889:0},ev=e=>{var r,t,n=e.__webpack_ids__,o=e.__webpack_modules__,a=e.__webpack_runtime__,i=0;for(r in o)eE.o(o,r)&&(eE.m[r]=o[r]);for(a&&a(eE);i<n.length;i++)t=n[i],eE.o(ey,t)&&ey[t]&&ey[t][0](),ey[n[i]]=0},eE.f.j=function(e,r){var t=eE.o(ey,e)?ey[e]:void 0;if(0!==t)if(t)r.push(t[1]);else{var n=import("./"+eE.u(e)).then(ev,r=>{throw 0!==ey[e]&&(ey[e]=void 0),r}),n=Promise.race([n,new Promise(r=>{t=ey[e]=[r]})]);r.push(t[1]=n)}},eE.ruid="bundler=rspack@1.5.2";var e_=["recordAction","bulkRecordAction","recordWidget","callRecordingInsightTextSelectionAction","callRecordingSummaryTextSelectionAction","callRecordingTranscriptTextSelectionAction","workspaceSettings","workflowBlock"];function eO(e){return e.charAt(0).toUpperCase()+e.slice(1)}var ek="\nexport interface ".concat(eO("recordAction")," {\n id: string\n label: string\n icon: string\n onTrigger: (record: {recordId: string; object: string}) => void | Promise<void>\n objects?: ObjectSlug | Array<ObjectSlug> | ((attributes: Array<Attribute>) => boolean)\n}\n"),eS="\nexport interface ".concat(eO("bulkRecordAction")," {\n id: string\n label: string\n icon: string\n onTrigger: (record: {recordIds: Array<string>; object: string}) => void | Promise<void>\n objects?: ObjectSlug | Array<ObjectSlug> | ((attributes: Array<Attribute>) => boolean)\n}\n"),eI="\nexport interface ".concat(eO("recordWidget")," {\n id: string\n Widget: (props: {recordId: string; object: ObjectSlug}) => React.JSX.Element\n objects?: ObjectSlug | Array<ObjectSlug> | ((attributes: Array<Attribute>) => boolean)\n}\n"),eT="\nexport interface ".concat(eO("callRecordingInsightTextSelectionAction")," {\n id: string\n label: string\n icon: string\n onTrigger: (selection: {text: string; markdown: string}) => void | Promise<void>\n}\n"),ex="\nexport interface ".concat(eO("callRecordingSummaryTextSelectionAction")," {\n id: string\n label: string\n icon: string\n onTrigger: (selection: {text: string; markdown: string}) => void | Promise<void>\n}\n"),eA="\nexport interface ".concat(eO("callRecordingTranscriptTextSelectionAction")," {\n id: string\n label: string\n icon: string\n onTrigger: (selection: {transcript: Array<{speaker: string; text: string}>; url: string}) => void | Promise<void>\n}\n"),eR="\nexport interface ".concat(eO("workflowBlock")," {\n id: string\n title: string\n description: string\n configSchema: Record<string, Node> | Struct\n configurator: React.ReactNode\n}\n"),ej="\nexport interface ".concat(eO("workspaceSettings")," {\n Page: React.ComponentType<{}>\n}\n"),eP="\n".concat(ek,"\n\n").concat(eS,"\n\n").concat(eI,"\n\n").concat(eT,"\n\n").concat(ex,"\n\n").concat(eA,"\n\n").concat(ej,"\n\n").concat(eR,"\n"),eN=function(e){var r=e.getBaseName();return r.endsWith(".ts")||r.endsWith(".tsx")};function eD(e){var r,t;function n(r,t){try{var a=e[r](t),i=a.value,c=i instanceof eL;Promise.resolve(c?i.v:i).then(function(t){if(c){var s="return"===r?"return":"next";if(!i.k||t.done)return n(s,t);t=e[s](t).value}o(a.done?"return":"normal",t)},function(e){n("throw",e)})}catch(e){o("throw",e)}}function o(e,o){switch(e){case"return":r.resolve({value:o,done:!0});break;case"throw":r.reject(o);break;default:r.resolve({value:o,done:!1})}(r=r.next)?n(r.key,r.arg):t=null}this._invoke=function(e,o){return new Promise(function(a,i){var c={key:e,arg:o,resolve:a,reject:i,next:null};t?t=t.next=c:(r=t=c,n(e,o))})},"function"!=typeof e.return&&(this.return=void 0)}function eC(e){function r(e){if(Object(e)!==e)return Promise.reject(TypeError(e+" is not an object."));var r=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:r}})}return(eC=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return r(this.n.apply(this.s,arguments))},return:function(e){var t=this.s.return;return void 0===t?Promise.resolve({value:e,done:!0}):r(t.apply(this.s,arguments))},throw:function(e){var t=this.s.return;return void 0===t?Promise.reject(e):r(t.apply(this.s,arguments))}},new eC(e)}function eF(e){return new eL(e,0)}function eL(e,r){this.v=e,this.k=r}eD.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},eD.prototype.next=function(e){return this._invoke("next",e)},eD.prototype.throw=function(e){return this._invoke("throw",e)},eD.prototype.return=function(e){return this._invoke("return",e)};var eU=["js","jsx","ts","tsx"],eM=["node_modules"];function eG(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function eB(e){function r(e){if(Object(e)!==e)return Promise.reject(TypeError(e+" is not an object."));var r=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:r}})}return(eB=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return r(this.n.apply(this.s,arguments))},return:function(e){var t=this.s.return;return void 0===t?Promise.resolve({value:e,done:!0}):r(t.apply(this.s,arguments))},throw:function(e){var t=this.s.return;return void 0===t?Promise.reject(e):r(t.apply(this.s,arguments))}},new eB(e)}function eV(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function eW(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){eV(a,n,o,i,c,"next",e)}function c(e){eV(a,n,o,i,c,"throw",e)}i(void 0)})}}function eJ(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function eY(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function eK(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function eH(e){return e.replace(/[^a-zA-Z0-9]+/g," ").trim().split(" ").map(function(e,r){return 0===r?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join("")}function eq(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function e$(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){eq(a,n,o,i,c,"next",e)}function c(e){eq(a,n,o,i,c,"throw",e)}i(void 0)})}}function eX(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var ez=["ts","tsx"];function eQ(e){return e$(function(){var r;return eX(this,function(t){switch(t.label){case 0:return[4,Promise.all(ez.map(function(r){return e$(function(){var t,n;return eX(this,function(o){switch(o.label){case 0:return t=u.join(e,"app.".concat(r)),[4,g(I.readFile(t))];case 1:if(O(n=o.sent()))return[2,null];return[2,{path:t,content:n.value.toString()}]}})})()}))];case 1:return[2,null!=(r=t.sent().find(function(e){return null!==e}))?r:null]}})})()}function eZ(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function e0(){var e,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(e=function(){var e,t;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:return[4,eQ(e=u.resolve("src"))];case 1:if(null!==n.sent())return[2,m(!0)];if(!r)return[2,w({code:"APP_ENTRY_POINT_NOT_FOUND"})];return[4,(t=S.createInterface({input:process.stdin,output:process.stdout})).question("Could not find app.ts entry point. Press Enter to generate it...")];case 2:var o,a;return n.sent(),t.close(),[4,(o=e,(a=function(){var e,r,t,n,a,i,c,s,l,f,p,d,h,b,y,v,E,k,S,A,R;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(j){var P;switch(j.label){case 0:return[4,eW(function(){var e,r,t,n,a,i,c,s,l,f,p,d,h,b,y,v;return eJ(this,function(g){switch(g.label){case 0:e=new Set,r=new Set,t=new T({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}),n=u.join(o,"".concat(Math.random().toString(36).slice(2),".").concat("ts")),i={recordAction:(a=t.createSourceFile(n,eP)).getInterfaceOrThrow("RecordAction").getType(),bulkRecordAction:a.getInterfaceOrThrow("BulkRecordAction").getType(),recordWidget:a.getInterfaceOrThrow("RecordWidget").getType(),callRecordingInsightTextSelectionAction:a.getInterfaceOrThrow("CallRecordingInsightTextSelectionAction").getType(),callRecordingSummaryTextSelectionAction:a.getInterfaceOrThrow("CallRecordingSummaryTextSelectionAction").getType(),callRecordingTranscriptTextSelectionAction:a.getInterfaceOrThrow("CallRecordingTranscriptTextSelectionAction").getType(),workspaceSettings:a.getInterfaceOrThrow("WorkspaceSettings").getType(),workflowBlock:a.getInterfaceOrThrow("WorkflowBlock").getType()},c=t.getTypeChecker(),s=[],l=[],f=!1,p=!1,g.label=1;case 1:g.trys.push([1,6,7,12]),h=function(e){var r,t,n,o=2;for("undefined"!=typeof Symbol&&(t=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(t&&null!=(r=e[t]))return r.call(e);if(n&&null!=(r=e[n]))return new eB(r.call(e));t="@@asyncIterator",n="@@iterator"}throw TypeError("Object is not async iterable")}(function e(r){var t;return(t=function(){var t,n,o,a,i,c,s,l,f,p,d,h,b,y,v,m,w,g,E,_,O,k;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(S){switch(S.label){case 0:return[4,eF(I.readdir(r,{withFileTypes:!0}))];case 1:t=S.sent(),n=[],o=!0,a=!1,i=void 0,S.label=2;case 2:S.trys.push([2,8,9,10]),c=t[Symbol.iterator](),S.label=3;case 3:if(o=(s=c.next()).done)return[3,7];if(l=s.value,f=u.join(r,l.name),!(l.isDirectory()&&!eM.includes(l.name)))return[3,4];return n.push(e(f)),[3,6];case 4:var T;if(T=f,!eU.some(function(e){return T.endsWith(".".concat(e))}))return[3,6];return[4,f];case 5:S.sent(),S.label=6;case 6:return o=!0,[3,3];case 7:return[3,10];case 8:return p=S.sent(),a=!0,i=p,[3,10];case 9:try{o||null==c.return||c.return()}finally{if(a)throw i}return[7];case 10:d=!0,h=!1,b=void 0,S.label=11;case 11:S.trys.push([11,27,28,29]),y=n[Symbol.iterator](),S.label=12;case 12:if(d=(v=y.next()).done)return[3,26];m=v.value,w=!1,g=!1,S.label=13;case 13:S.trys.push([13,19,20,25]),_=function(e){var r,t,n,o=2;for("undefined"!=typeof Symbol&&(t=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(t&&null!=(r=e[t]))return r.call(e);if(n&&null!=(r=e[n]))return new eC(r.call(e));t="@@asyncIterator",n="@@iterator"}throw TypeError("Object is not async iterable")}(m),S.label=14;case 14:return[4,eF(_.next())];case 15:if(!(w=!(O=S.sent()).done))return[3,18];return[4,O.value];case 16:S.sent(),S.label=17;case 17:return w=!1,[3,14];case 18:return[3,25];case 19:return k=S.sent(),g=!0,E=k,[3,25];case 20:if(S.trys.push([20,,23,24]),!(w&&null!=_.return))return[3,22];return[4,eF(_.return())];case 21:S.sent(),S.label=22;case 22:return[3,24];case 23:if(g)throw E;return[7];case 24:return[7];case 25:return d=!0,[3,12];case 26:return[3,29];case 27:return p=S.sent(),h=!0,b=p,[3,29];case 28:try{d||null==y.return||y.return()}finally{if(h)throw b}return[7];case 29:return[2]}})},function(){return new eD(t.apply(this,arguments))})()}(o)),g.label=2;case 2:return[4,h.next()];case 3:if(!(f=!(b=g.sent()).done))return[3,5];y=b.value,s.push(eW(function(){var e,r;return eJ(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,I.readFile(y,"utf-8")];case 1:return e=n.sent(),[2,m(t.createSourceFile(y,e,{overwrite:!0}))];case 2:if((void 0===(r=n.sent())?"undefined":r&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)=="object"&&null!==r&&"code"in r&&"ENOENT"===r.code)return[2,w({code:"FILE_NOT_FOUND"})];return[2,w({code:"UNKNOWN_ERROR"})];case 3:return[2]}})})()),g.label=4;case 4:return f=!1,[3,2];case 5:return[3,12];case 6:return v=g.sent(),p=!0,d=v,[3,12];case 7:if(g.trys.push([7,,10,11]),!(f&&null!=h.return))return[3,9];return[4,h.return()];case 8:g.sent(),g.label=9;case 9:return[3,11];case 10:if(p)throw d;return[7];case 11:return[7];case 12:return[4,Promise.all(s)];case 13:return g.sent().filter(function(e){return _(e)}).map(function(t){var n=function(e){var r=e.sourceFile,t=e.existingExportSymbols,n=e.existingIds,o=e.typeChecker,a=e.surfaceTypes,i=new Set,c=r.getFilePath(),s=r.getExportedDeclarations(),u=!0,l=!1,f=void 0;try{for(var p,d=e_[Symbol.iterator]();!(u=(p=d.next()).done);u=!0)!function(){var e,u,l=p.value,f=s.get(l);if(!f)return;var d=f[0],h=null!=(u=(e=d.getSymbol())&&o.getAliasedSymbol(e))?u:e;if(!(!h||t.has(h))){var b=d.getType();if(eN(r)&&!o.isTypeAssignableTo(b,a[l])){var y=d.getFirstChild()||d;throw{errors:[{text:"".concat(l," in ").concat(c," is not assignable to ").concat(eO(l)),location:{file:c,line:y.getStartLineNumber(),column:0,lineText:d.getText().split("\n")[0],additionalLines:d.getText().split("\n").slice(1),length:y.getWidth(),namespace:l,suggestion:"Ensure the export matches the type ".concat(eO(l))}}]}}var v=function(e){if(d.getKind()!==x.VariableDeclaration)throw Error("".concat(l," is not an object in ").concat(c," ").concat(d.getKind()));var r=d.asKindOrThrow(x.VariableDeclaration).getInitializer();if((null==r?void 0:r.getKind())!==x.ObjectLiteralExpression)throw Error("".concat(l," must be defined as an object literal expression in ").concat(c));var t=r.asKindOrThrow(x.ObjectLiteralExpression).getProperty("id");if((null==t?void 0:t.getKind())!==x.PropertyAssignment)throw Error("Property ".concat("id"," on ").concat(l," must be directly declared in the object declaration in ").concat(c));var n=t.asKindOrThrow(x.PropertyAssignment).getInitializer();if((null==n?void 0:n.getKind())!==x.StringLiteral)throw Error("Property ".concat(e," on ").concat(l," must be a string literal in ").concat(c));return n.asKindOrThrow(x.StringLiteral).getLiteralValue()}("id");if(n.has(v))throw{errors:[{text:"Duplicate surface id ".concat(v),location:{file:c,line:d.getStartLineNumber(),column:0,length:d.getWidth(),lineText:d.getText().split("\n")[0],additionalLines:d.getText().split("\n").slice(1),namespace:l,suggestion:"Ensure the id is unique"}}]};t.add(h),n.add(v),i.add({surfaceType:l,id:v})}}()}catch(e){l=!0,f=e}finally{try{u||null==d.return||d.return()}finally{if(l)throw f}}return i}({sourceFile:t.value,existingExportSymbols:e,existingIds:r,typeChecker:c,surfaceTypes:i});n.size>0&&l.push([t.value.getFilePath(),function(e){if(Array.isArray(e))return eG(e)}(n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||function(e,r){if(e){if("string"==typeof e)return eG(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return eG(e,r)}}(n)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()])}),[2,l]}})})()];case 1:e=j.sent(),r=e_.reduce(function(e,r){return e[r]=[],e},{}),t=!0,n=!1,a=void 0;try{for(i=e[Symbol.iterator]();!(t=(c=i.next()).done);t=!0){P=c.value,l=(s=function(e){if(Array.isArray(e))return e}(P)||function(e,r){var t,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(t=o.next()).done)&&(a.push(t.value),a.length!==r);i=!0);}catch(e){c=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw n}}return a}}(P,2)||function(e,r){if(e){if("string"==typeof e)return eY(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return eY(e,r)}}(P,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],f=s[1],p=!0,d=!1,h=void 0;try{for(b=f[Symbol.iterator]();!(p=(y=b.next()).done);p=!0)r[(v=y.value).surfaceType].push({importPath:function(e,r){var t=u.relative(e,r).split(u.sep).join("/").replace(/\.[^/.]+$/,"");return t.startsWith(".")?t:"./".concat(t)}(o,l),id:v.id})}catch(e){d=!0,h=e}finally{try{p||null==b.return||b.return()}finally{if(d)throw h}}}}catch(e){n=!0,a=e}finally{try{t||null==i.return||i.return()}finally{if(n)throw a}}return E=e_.flatMap(function(e){return r[e].map(function(r){var t=eH(r.id);return"import {".concat(e).concat(t!==e?" as ".concat(t):"","} from ").concat(JSON.stringify(r.importPath))})}).join("\n"),S=(k=e_.reduce(function(e,t){return e[t]=r[t].map(function(e){return eH(e.id)}),e},{})).callRecordingInsightTextSelectionAction.length>0||k.callRecordingSummaryTextSelectionAction.length>0||k.callRecordingTranscriptTextSelectionAction.length>0,A=['import type {App} from "attio"\n',E,"\nexport const app: App = {\n record: {\n actions: [".concat(k.recordAction.join(", "),"],\n bulkActions: [").concat(k.bulkRecordAction.join(", "),"],").concat(k.recordWidget.length>0?"\n widgets: [".concat(k.recordWidget.join(", "),"],"):"","\n },").concat(S?"\n callRecording: {\n insight: {\n textActions: [".concat(k.callRecordingInsightTextSelectionAction.join(", "),"],\n },\n summary: {\n textActions: [").concat(k.callRecordingSummaryTextSelectionAction.join(", "),"],\n },\n transcript: {\n textActions: [").concat(k.callRecordingTranscriptTextSelectionAction.join(", "),"],\n },\n },"):"","\n}\n")].join("\n"),[4,g(I.writeFile(u.join(o,"app.ts"),A))];case 2:if(O(R=j.sent()))return[2,R];return[2,m(!0)]}})},function(){var e=this,r=arguments;return new Promise(function(t,n){var o=a.apply(e,r);function i(e){eK(o,t,n,i,c,"next",e)}function c(e){eK(o,t,n,i,c,"throw",e)}i(void 0)})})())];case 3:if(O(n.sent()))return[2,w({code:"FAILED_TO_GENERATE_ENTRY_POINT"})];return[2,m(!0)]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){eZ(a,n,o,i,c,"next",e)}function c(e){eZ(a,n,o,i,c,"throw",e)}i(void 0)})})()}function e1(e){A.stderr.write(R.red("✖ "+e)+"\n"),A.exit(1)}function e2(){var e,r,t,n;e1("Could not find app.ts. Run `".concat(null!=(t=({npm:"npm run ".concat("dev"),yarn:"yarn ".concat("dev"),pnpm:"pnpm ".concat("dev"),bun:"bun run ".concat("dev")})[null!=(n=null==(r=process.env.npm_config_user_agent)||null==(e=r.split("/"))?void 0:e[0])?n:"npm"])?t:"npm run ".concat("dev"),"` to generate it. See https://docs.attio.com/sdk/guides/app-ts-migration"))}var e4=".attio",e3="app.settings.ts";function e6(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function e5(){var e;return(e=function(){var e,r,t;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:e=u.resolve("."),r=u.join(e,e4),t=u.join(r,"settings.d.ts"),n.label=1;case 1:return n.trys.push([1,4,,5]),[4,I.mkdir(r,{recursive:!0})];case 2:return n.sent(),[4,I.writeFile(t,'import "attio"\n\nimport type appSettingsSchema from "../src/app.settings"\n\ndeclare module "attio" {\n export interface AppSettingsSchema {\n workspace: (typeof appSettingsSchema)["workspace"]\n }\n}\n')];case 3:return n.sent(),[2,m(void 0)];case 4:return n.sent(),[2,w({code:"FAILED_TO_CREATE_SETTINGS_TYPES_FILE"})];case 5:return[2]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){e6(a,n,o,i,c,"next",e)}function c(e){e6(a,n,o,i,c,"throw",e)}i(void 0)})})()}function e7(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function e8(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var e9=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],re=function(){"use strict";var e;function r(){if(!(this instanceof r))throw TypeError("Cannot call a class as a function");e8(this,"frameIndex",0),e8(this,"stopped",!1),e8(this,"interval",null),e8(this,"message","")}return e=[{key:"start",value:function(e){var r=this;return this.interval&&clearInterval(this.interval),this.message=e,this.stopped=!1,this.interval=setInterval(function(){if(!r.stopped){var e=e9[r.frameIndex=++r.frameIndex%e9.length];process.stdout.write("\r".concat(e," ").concat(r.message))}},80),this}},{key:"update",value:function(e){return this.message=e,this}},{key:"stop",value:function(e){return this.stopped=!0,this.interval&&(clearInterval(this.interval),this.interval=null),e&&process.stdout.write("\r".concat(e," \n")),this}},{key:"success",value:function(e){return this.stop("".concat(R.green("✓")," ").concat(e))}},{key:"error",value:function(e){return this.stop("".concat(R.red("✖")," ").concat(e))}},{key:"warning",value:function(e){return this.stop("".concat(R.yellow("⚠")," ").concat(e))}}],function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,e),r}();function rr(e,r,t){var n;return(n=function(){var n,o;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(a){switch(a.label){case 0:(n=new re).start(e),a.label=1;case 1:return a.trys.push([1,,3,4]),[4,t()];case 2:return _(o=a.sent())&&n.success("string"==typeof r?r:r(o.value)),[2,o];case 3:return n.stop(),[7];case 4:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(t,o){var a=n.apply(e,r);function i(e){e7(a,t,o,i,c,"next",e)}function c(e){e7(a,t,o,i,c,"throw",e)}i(void 0)})})()}function rt(e){function r(e){if(Object(e)!==e)return Promise.reject(TypeError(e+" is not an object."));var r=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:r}})}return(rt=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return r(this.n.apply(this.s,arguments))},return:function(e){var t=this.s.return;return void 0===t?Promise.resolve({value:e,done:!0}):r(t.apply(this.s,arguments))},throw:function(e){var t=this.s.return;return void 0===t?Promise.reject(e):r(t.apply(this.s,arguments))}},new rt(e)}function rn(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function ro(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){rn(a,n,o,i,c,"next",e)}function c(e){rn(a,n,o,i,c,"throw",e)}i(void 0)})}}function ra(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var ri={getCanonicalFileName:function(e){return e},getCurrentDirectory:N.sys.getCurrentDirectory,getNewLine:function(){return"\n"}},rc=b.object({text:b.string(),location:b.object({file:b.string(),lineText:b.string(),line:b.number(),character:b.number(),endCharacter:b.number()}).optional()}),rs=function(e){return ro(function(){return ra(this,function(r){return[2,new Promise(function(r,t){if(!i(e))return void r("Not a TypeScript project");var n=N.readConfigFile(e,N.sys.readFile),o=n.config,a=n.error;if(a)t(rc.parse({text:N.formatDiagnostic(a,ri)}));else{var c=N.parseJsonConfigFileContent(o,N.sys,"./");r(N.createProgram({rootNames:c.fileNames,options:c.options}))}})]})})()},ru=function(e){return ro(function(){return ra(this,function(r){switch(r.label){case 0:return[4,Promise.all(N.getPreEmitDiagnostics(e).map(function(e){return ro(function(){var r,t,n,o,i,c,s;return ra(this,function(u){switch(u.label){case 0:var l,f;if(r=N.flattenDiagnosticMessageText(e.messageText,"\n"),!e.file)return[3,2];return n=(t=e.file.getLineAndCharacterOfPosition(e.start)).line,o=t.character,i=e.start+e.length,c=e.file.getLineAndCharacterOfPosition(i).character,[4,(l=e.file.fileName,f=n,ro(function(){var e,r,t,n,o,i,c,s,u,p;return ra(this,function(d){switch(d.label){case 0:r=P({input:e=a(l),crlfDelay:1/0}),t=0,n=!1,o=!1,d.label=1;case 1:d.trys.push([1,6,7,12]),c=function(e){var r,t,n,o=2;for("undefined"!=typeof Symbol&&(t=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(t&&null!=(r=e[t]))return r.call(e);if(n&&null!=(r=e[n]))return new rt(r.call(e));t="@@asyncIterator",n="@@iterator"}throw TypeError("Object is not async iterable")}(r),d.label=2;case 2:return[4,c.next()];case 3:if(!(n=!(s=d.sent()).done))return[3,5];if(u=s.value,(t+=1)===f+1)return r.close(),e.close(),[2,u];d.label=4;case 4:return n=!1,[3,2];case 5:return[3,12];case 6:return p=d.sent(),o=!0,i=p,[3,12];case 7:if(d.trys.push([7,,10,11]),!(n&&null!=c.return))return[3,9];return[4,c.return()];case 8:d.sent(),d.label=9;case 9:return[3,11];case 10:if(o)throw i;return[7];case 11:return[7];case 12:return[2,null]}})})())];case 1:return s=u.sent(),[2,rc.parse({text:r,location:{file:e.file.fileName,line:n,character:o,endCharacter:c,lineText:s}})];case 2:return[2,rc.parse({text:r})];case 3:return[2]}})})()}))];case 1:return[2,r.sent()]}})})()};function rl(e){if(!e.location)return void process.stderr.write("".concat(R.red("\xd7")," – ").concat(e.text,"\n"));var r,t=e.location.line.toLocaleString().padStart(3," "),n=t.length,o=" ".repeat(n),a=e.location.lineText,i=(null==(r=a.match(/^\s*/))?void 0:r[0].length)||0,c=a.trimStart(),s=c.slice(0,e.location.character-i),u=c.slice(e.location.character-i,e.location.endCharacter-i),l=c.slice(e.location.endCharacter-i);process.stderr.write("".concat(" ".repeat(n-2)," ").concat(R.red("\xd7")," ").concat(e.text,"\n\n")),process.stderr.write("".concat(o," ╭─── ").concat(R.bold(e.location.file),"\n")),process.stderr.write("".concat(t," │ ").concat(s).concat(R.red(u)).concat(l,"\n")),process.stderr.write("".concat(o," │ ").concat(" ".repeat(Math.max(0,e.location.character-i))).concat(R.red("~".repeat(Math.max(0,e.location.endCharacter-e.location.character))),"\n")),process.stderr.write("".concat(o," ╰───\n\n"))}function rf(e,r){if(!e.location)return void process.stderr.write("".concat(R.red("\xd7")," – ").concat(e.text,"\n"));var t,n=e.location.line.toLocaleString().padStart(3," "),o=n.length,a=" ".repeat(o),i=e.location.lineText,c=(null==(t=i.match(/^\s*/))?void 0:t[0].length)||0,s=i.trimStart(),u=s.slice(0,e.location.column-c),l=s.slice(e.location.column-c,e.location.column+e.location.length-c),f=s.slice(e.location.column+e.location.length-c);process.stderr.write("".concat(" ".repeat(o-2)," ").concat("error"===r?R.red("\xd7"):"\uD83D\uDEA7"," ").concat(e.text,"\n\n")),process.stderr.write("".concat(a," ╭─── ").concat(R.bold(e.location.file),"\n")),process.stderr.write("".concat(n," │ ").concat(u).concat(R.red(l)).concat(f,"\n")),process.stderr.write("".concat(a," │ ").concat(" ".repeat(Math.max(0,e.location.column-c))).concat(R.red("~".repeat(e.location.length)),"\n")),process.stderr.write("".concat(a," ╰───\n\n"))}function rp(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function rd(e,r){return r(e)?e:null}function rh(e,r){return rd(e+".ts",r)||rd(e+".tsx",r)||rd(e+".js",r)}function rb(e,r,t){var n=rh(rv(e,r),t.doesModuleExist);if(!n)throw Error("Unable to resolve path for module ".concat(e," from ").concat(r));var o=t.modules;if(o.has(n))return o.get(n);var a=t.getModuleSource(n),i=C(a,{range:!0,jsx:!0}),c=F(i,{sourceType:"module"}).acquire(i,!0),s=new Map,u={content:a,ast:i,scope:c,namedExports:s,path:n};return o.set(n,u),L(i,null,{ExportNamedDeclaration:function(e){var r;if((null==(r=e.declaration)?void 0:r.type)==="VariableDeclaration"&&1===e.declaration.declarations.length&&"VariableDeclarator"===e.declaration.declarations[0].type&&"Identifier"===e.declaration.declarations[0].id.type){var t=e.declaration.declarations[0],n=t.id,o=t.init;if((null==o?void 0:o.type)==="Identifier"){var a=ry(o,c);if((null==a?void 0:a.type)!=="ImportBinding")return void s.set(n.name,t.init)}s.set(n.name,t.init)}if(null==e?void 0:e.specifiers){var i=!0,u=!1,l=void 0;try{for(var f,p=e.specifiers[Symbol.iterator]();!(i=(f=p.next()).done);i=!0){var d=f.value;if("ExportSpecifier"===d.type&&"Identifier"===d.exported.type&&"Identifier"===d.local.type)if(null!==e.source)s.set(d.exported.name,e);else{var h=ry(d.local,c);s.set(d.exported.name,h)}}}catch(e){u=!0,l=e}finally{try{i||null==p.return||p.return()}finally{if(u)throw l}}}}}),u}function ry(e,r){var t=r.set.get(e.name);if(!t)throw Error("Unable to find variable ".concat(e.name," in scope"));if(1!==t.defs.length)throw Error("Expected exactly one definition for variable ".concat(e.name,", found ").concat(t.defs.length));var n=t.defs[0];return"VariableDeclarator"===n.node.type?n.node.init:"ImportBinding"==n.type?n:null}function rv(e,r){if(e.startsWith(".")){var t=(r.split("/").slice(0,-1).join("/")+"/"+e).split("/"),n=[],o=!0,a=!1,i=void 0;try{for(var c,s=t[Symbol.iterator]();!(o=(c=s.next()).done);o=!0){var u=c.value;".."===u?n.pop():"."!==u&&n.push(u)}}catch(e){a=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}return n.join("/")}return e}function rm(e,r,t,n,o){var a="Identifier"===r.type?ry(r,t):r;if(!a||"ImportBinding"!==a.type&&"ExportNamedDeclaration"!==a.type)throw Error("Expected parent of import binding to be an import binding");var i=("ExportNamedDeclaration"===a.type?a:a.parent).source.value,c=rv(i,n);if(i.endsWith(".server"))throw Error('Unexpected .server import, did you mean to import "'.concat(e,'" from a .block file?'));if(!i.endsWith(".block")&&!i.endsWith(".block.ts")&&!i.endsWith(".block.tsx")&&!i.endsWith(".block.js")){var s=rb(i,c,o);if(!s.namedExports.has(e))throw Error("Unable to find named export ".concat(e," in module ").concat(i));var u=s.namedExports.get(e);return rm(e,u,s.scope,s.path,o)}var l=e;return"ImportBinding"===a.type&&a.name.name!==e&&(l=a.name.name),{path:c=rh(c,o.doesModuleExist)||c,export:l}}function rw(e,r,t,n,o){if("Identifier"===e.type){var a=r,i=ry(e,r),c=n;if((null==i?void 0:i.type)==="ImportBinding"){var s=i.parent,u=rb(s.source.value,n,o),l=i.name.name,f=s.specifiers.find(function(e){return e.local.name===l}),p=(null==f?void 0:f.imported).name;if(!u.namedExports.has(p))throw Error("Unable to find named export ".concat(p," in module ").concat(s.source.value));i=u.namedExports.get(p),a=u.scope,c=u.path}if(!i||"ObjectExpression"!==i.type)throw Error("Expected variable ".concat(e.name," to have an initializer"));rw(i,a,t,c,o);return}if("ObjectExpression"===e.type){var d=!0,h=!1,b=void 0;try{for(var y,v,m,w,g,E,_,O,k=e.properties[Symbol.iterator]();!(d=(O=k.next()).done);d=!0){var S=O.value;if("Property"===S.type&&"Identifier"===S.key.type){var I=S.key.name;if("id"===I){if("Literal"!==S.value.type||"string"!=typeof S.value.value)throw Error("Expected block id to be a string literal");y=S.value.value}else"execute"===I?v=rm(I,S.value,r,n,o):"deferCallback"===I?m=rm(I,S.value,r,n,o):"schema"===I?w=rm(I,S.value,r,n,o):"activate"===I?g=rm(I,S.value,r,n,o):"triggerCallback"===I?E=rm(I,S.value,r,n,o):"deactivate"===I&&(_=rm(I,S.value,r,n,o))}}}catch(e){h=!0,b=e}finally{try{d||null==k.return||k.return()}finally{if(h)throw b}}if(!y||!w)throw Error("Expected block to have id and schema properties");t.set(y,{execute:v,deferCallback:m,schema:w,activate:g,triggerCallback:E,deactivate:_})}}function rg(e,r,t){var n=e.properties.find(function(e){return"Property"===e.type&&"Identifier"===e.key.type&&e.key.name===r});if(!n)return null;var o=n.value;if("Identifier"===o.type){var a=ry(o,t);a&&(null==a?void 0:a.type)!=="ImportBinding"&&(o=a)}return o}function rE(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function r_(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var rO="proxy-block-modules-plugin";function rk(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var rS="proxy-server-modules-plugin";function rI(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var rT=b.object({text:b.string(),location:b.object({column:b.number(),file:b.string(),length:b.number(),line:b.number(),lineText:b.string(),additionalLines:b.array(b.string()).optional(),namespace:b.string(),suggestion:b.string()})}),rx=b.object({errors:b.array(rT).optional().readonly(),warnings:b.array(rT).optional().readonly()});function rA(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function rR(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){rA(a,n,o,i,c,"next",e)}function c(e){rA(a,n,o,i,c,"throw",e)}i(void 0)})}}function rj(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function rP(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function rN(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var rD=function(){"use strict";var e,r;function t(e){var r=e.tempFile,n=e.directories,o=e.workflowBlockModulesRef,a=e.esbuildContext;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");rP(this,"_lastJs",void 0),rP(this,"_esbuildContext",void 0),rP(this,"_tempFile",void 0),rP(this,"_directories",void 0),rP(this,"_workflowBlockModulesRef",void 0),this._esbuildContext=a,this._tempFile=r,this._workflowBlockModulesRef=o,this._directories=n}return e=[{key:"rebuild",value:function(e){return rR(function(e){var r,t,n,o,a,i,c,s;return rN(this,function(l){switch(l.label){case 0:return r=e.workflowBlockModules,this._workflowBlockModulesRef.current=r,[4,function(e){var r;return(r=function(e){var r,t,n,o;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(a){switch(a.label){case 0:return[4,eQ(r=e.srcDirAbsolute)];case 1:if(!(t=a.sent()))return[2,w({code:"APP_ENTRY_POINT_NOT_FOUND"})];if(!new T({useInMemoryFileSystem:!0}).createSourceFile(t.path,t.content).getExportedDeclarations().has("app"))return[2,w({code:"APP_EXPORT_NOT_FOUND",path:t.path})];return[4,g(I.readFile(u.join(r,e3)))];case 2:return n=_(a.sent())?"\n import appSettingsSchema from ".concat(JSON.stringify(u.join(r,e3)),"\n\n registerSettingsSchema(appSettingsSchema)\n "):"\n registerSettingsSchema({workspace: {}})\n ",o="\n import {app} from ".concat(JSON.stringify(t.path),"\n "),[2,m("\n ".concat(o,"\n\n ").concat(n,"\n\n ").concat('\n const recordActions = app?.record?.actions\n const bulkRecordActions = app?.record?.bulkActions\n const recordWidgets = app?.record?.widgets\n const callRecordingInsights = app?.callRecording?.insight?.textActions\n const callRecordingSummaries = app?.callRecording?.summary?.textActions\n const callRecordingTranscripts = app?.callRecording?.transcript?.textActions\n const workflowStepBlocks = app?.workflow?.blocks?.steps\n const workflowTriggerBlocks = app?.workflow?.blocks?.triggers\n const workspaceSettings = app?.settings?.workspace\n\n registerSurfaces({\n "record-action": Array.isArray(recordActions) ? recordActions : [],\n "bulk-record-action": Array.isArray(bulkRecordActions) ? bulkRecordActions : [],\n "record-widget": Array.isArray(recordWidgets) ? recordWidgets : [],\n "call-recording-insight-text-selection-action": Array.isArray(callRecordingInsights) ? callRecordingInsights : [],\n "call-recording-summary-text-selection-action": Array.isArray(callRecordingSummaries) ? callRecordingSummaries : [],\n "call-recording-transcript-text-selection-action": Array.isArray(callRecordingTranscripts) ? callRecordingTranscripts : [],\n "workflow-block": [\n ...(Array.isArray(workflowStepBlocks)\n ? workflowStepBlocks.map((block) => ({type: "step", id: block.id, block}))\n : []),\n ...(Array.isArray(workflowTriggerBlocks)\n ? workflowTriggerBlocks.map((block) => ({type: "trigger", id: block.id, block}))\n : []),\n ],\n "workspace-settings": workspaceSettings ? [workspaceSettings] : [],\n })\n ',"\n "))]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(e){rI(a,n,o,i,c,"next",e)}function c(e){rI(a,n,o,i,c,"throw",e)}i(void 0)})}).apply(this,arguments)}({srcDirAbsolute:u.resolve(this._directories.src)})];case 1:if(O(t=l.sent()))return[2,t];if((n=t.value)===this._lastJs)return[3,5];l.label=2;case 2:return l.trys.push([2,4,,5]),[4,I.writeFile(this._tempFile.path,n)];case 3:return l.sent(),this._lastJs=n,[3,5];case 4:return o=l.sent(),[2,w({code:"FAILED_TO_CREATE_TEMP_FILE",path:this._tempFile.path,error:o})];case 5:return l.trys.push([5,7,,8]),[4,this._esbuildContext.rebuild()];case 6:return[2,m.apply(void 0,[l.sent()])];case 7:if(a=l.sent(),!(i=rx.safeParse(a)).success)return[2,w({code:"UNPARSABLE_BUILD_ERROR",error:a})];return[2,w({code:"BUILD_JAVASCRIPT_ERROR",errors:null!=(c=i.data.errors)?c:[],warnings:null!=(s=i.data.warnings)?s:[]})];case 8:return[2]}})}).apply(this,arguments)}},{key:"dispose",value:function(e){return rR(function(){return rN(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,Promise.race([Promise.all([this._esbuildContext.dispose(),this._tempFile.cleanup()]),new Promise(function(r,t){return setTimeout(function(){return t(Error("Context disposal timeout"))},e)})])];case 1:return r.sent(),[3,3];case 2:return[2,w({code:"FAILED_TO_DISPOSE_OF_BUILD_CONTEXT",error:r.sent()})];case 3:return[2,m(void 0)]}})}).call(this)}}],r=[{key:"create",value:function(e){return rR(function(e){var r,n,o,a,i,c;return rN(this,function(s){switch(s.label){case 0:r=e.outfile,n=e.directories,o=e.mode,s.label=1;case 1:return s.trys.push([1,4,,5]),a={current:new Map},[4,M.file({postfix:".js"})];case 2:var l,f;return i=s.sent(),[4,U((l=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(r){rP(e,r,t[r])})}return e}({},function(e){var r,t,n,o,a=e.appDir,i=e.srcDir,c=e.entryPoint,s=e.workflowBlockModulesRef;return{entryPoints:[c],logLevel:"silent",bundle:!0,platform:"browser",format:"iife",sourcemap:("true"===(null!=(o=process.env.ATTIO_COVERAGE)?o:"").toLowerCase()||"1"===process.env.ATTIO_COVERAGE)&&"inline",plugins:[G({react:{varName:"React",type:"cjs",namedExports:["default","Children","Component","Fragment","Profiler","PureComponent","StrictMode","Suspense","SuspenseList","cloneElement","createContext","createElement","createFactory","createRef","forwardRef","isValidElement","lazy","memo","startTransition","unstable_SuspenseList","useCallback","useContext","useDebugValue","useDeferredValue","useEffect","useId","useImperativeHandle","useInsertionEffect","useLayoutEffect","useMemo","useReducer","useRef","useState","useSyncExternalStore","useTransition"]},attio:{varName:"ATTIO_ROOT_SDK",type:"cjs"},"attio/client":{varName:"ATTIO_CLIENT_EXTENSION_SDK",type:"cjs"}}),{name:rS,setup:function(e){e.onResolve({filter:/\.server$/},function(e){var r=u.relative(i,u.resolve(e.resolveDir,e.path));return{path:e.path,namespace:rS,pluginData:{moduleHash:r}}}),e.onLoad({filter:/.*/,namespace:rS},function(e){var r;return(r=function(){return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){var t;return[2,{contents:(t=e.pluginData.moduleHash,"\nexport default async function(...args) {\n return runServerFunction(".concat(JSON.stringify(t),", args)\n}")),loader:"js"}]})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(e){rk(a,n,o,i,c,"next",e)}function c(e){rk(a,n,o,i,c,"throw",e)}i(void 0)})})()})}},(t=(r={appDir:a,workflowBlockModulesRef:s}).appDir,n=r.workflowBlockModulesRef,{name:rO,setup:function(e){e.onResolve({filter:/\.block$/},function(e){var r=u.relative(t,u.resolve(e.resolveDir,e.path))+".ts";return{path:e.path,namespace:rO,pluginData:{modulePath:r}}}),e.onLoad({filter:/.*/,namespace:rO},function(e){var r;return(r=function(){return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){return[2,{contents:function(e,r){var t,n=0,o=new Map,a=!0,i=!1,c=void 0;try{for(var s,u=r.current.values()[Symbol.iterator]();!(a=(s=u.next()).done);a=!0){for(var l=s.value,f=l.execute,p=l.deferCallback,d=l.schema,h=l.activate,b=l.triggerCallback,y=l.deactivate,v=0,m=[f,p,h,b,y];v<m.length;v++){var w=m[v];w&&w.path===e&&("default"===w.export?o.set("default",'export default async function() {\n throw new Error("Exports from *.block.ts files cannot be called from the client.")\n}'):o.set(w.export,"export async function ".concat(w.export,'() {\n throw new Error("Exports from *.block.ts files cannot be called from the client.")\n}')))}if(d&&d.path===e)if("default"===d.export){var g=void 0;do g="schema_".concat(n++);while(!o.has(g));o.set("default","const ".concat(g,' = new Proxy({}, {\n get() {\n throw new Error("Exports from *.block.ts files cannot be called from the client.");\n }\n});\n\nexport default ').concat(g,";"))}else o.set(d.export,"export const ".concat(d.export,' = new Proxy({}, {\n get() {\n throw new Error("Exports from *.block.ts files cannot be called from the client.");\n }\n});'))}}catch(e){i=!0,c=e}finally{try{a||null==u.return||u.return()}finally{if(i)throw c}}return((function(e){if(Array.isArray(e))return rE(e)})(t=o.values())||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,r){if(e){if("string"==typeof e)return rE(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return rE(e,r)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).join("\n")}(e.pluginData.modulePath,n),loader:"js"}]})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(e){r_(a,n,o,i,c,"next",e)}function c(e){r_(a,n,o,i,c,"throw",e)}i(void 0)})})()})}})]}}({appDir:n.app,entryPoint:i.path,srcDir:n.src,workflowBlockModulesRef:a})),f=f={write:"write-to-disk"===o,outfile:r,loader:{".png":"dataurl",".graphql":"text",".gql":"text"}},Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(f)):(function(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(f)).forEach(function(e){Object.defineProperty(l,e,Object.getOwnPropertyDescriptor(f,e))}),l))];case 3:return[2,m(new t({esbuildContext:s.sent(),tempFile:i,workflowBlockModulesRef:a,directories:n}))];case 4:return c=s.sent(),[2,w({code:"FAILED_TO_CREATE_ESBUILD_CONTEXT",outfile:r,error:c})];case 5:return[2]}})}).apply(this,arguments)}}],e&&rj(t.prototype,e),r&&rj(t,r),t}();function rC(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function rF(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function rL(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){rF(a,n,o,i,c,"next",e)}function c(e){rF(a,n,o,i,c,"throw",e)}i(void 0)})}}function rU(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(t=o.next()).done)&&(a.push(t.value),!r||a.length!==r);i=!0);}catch(e){c=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw n}}return a}}(e,r)||rG(e,r)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function rM(e){return function(e){if(Array.isArray(e))return rC(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||rG(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function rG(e,r){if(e){if("string"==typeof e)return rC(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return rC(e,r)}}function rB(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function rV(e,r){return rL(function(){return rB(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,B("**/*.".concat(r,".{js,ts}"),{nodir:!0,cwd:e})];case 1:return[2,m.apply(void 0,[t.sent()])];case 2:return[2,w({code:"ERROR_FINDING_SERVER_FUNCTION_MODULES",path:e,pattern:r,cause:t.sent()})];case 3:return[2]}})})()}function rW(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function rJ(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){rW(a,n,o,i,c,"next",e)}function c(e){rW(a,n,o,i,c,"throw",e)}i(void 0)})}}function rY(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function rK(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function rH(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var rq=function(){"use strict";var e,r;function t(e){var r=e.esbuildContext,n=e.tempFile,o=e.directories;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");rK(this,"_lastJs",void 0),rK(this,"_esbuildContext",void 0),rK(this,"_tempFile",void 0),rK(this,"_directories",void 0),this._esbuildContext=r,this._tempFile=n,this._directories=o}return e=[{key:"rebuild",value:function(e){return rJ(function(e){var r,t,n,o,a,i,c,s;return rH(this,function(l){switch(l.label){case 0:return r=e.workflowBlockModules,[4,function(e){return rL(function(e){var r,t,n,o,a,i,c,s,l,f,p,d,h,b,y,w,E,k,S,T,x;return rB(this,function(A){switch(A.label){case 0:return r=e.appDirAbsolute,t=e.srcDirAbsolute,n=e.webhooksDirAbsolute,o=e.eventDirAbsolute,a=e.workflowBlockModules,i=e.log,[4,v({serverFunctionConcretePaths:rV(t,"server"),webhookConcretePaths:rV(n,"webhook"),eventConcretePaths:rV(o,"event")})];case 1:if(O(c=A.sent()))return[2,c];l=(s=c.value).serverFunctionConcretePaths,f=s.webhookConcretePaths,p=s.eventConcretePaths,d=l.map(function(e){return{path:e,hash:e.replace(/\.(js|ts)$/,"")}}),h=f.map(function(e){return{path:e,id:e.replace(/\.webhook\.(js|ts)$/,"")}}),b=p.map(function(e){return{path:e,id:e.replace(/\.event\.(js|ts)$/,"")}}),y=!0,w=!1,E=void 0;try{for(k=d[Symbol.iterator]();!(y=(S=k.next()).done);y=!0)T=S.value,null==i||i('\uD83D\uDD0E Found server module "'.concat(T.path,'"'))}catch(e){w=!0,E=e}finally{try{y||null==k.return||k.return()}finally{if(w)throw E}}return[4,g(I.readFile(u.join(t,e3)))];case 2:return x=_(A.sent())?"\n import appSettingsSchema from ".concat(JSON.stringify(u.join(t,e3)),"\n\n registerSettingsSchema(appSettingsSchema)\n "):"\n registerSettingsSchema({workspace: {}})\n ",[2,m("\n ".concat(x,"\n\n const modules = new Map()\n const webhookModules = new Map()\n const eventModules = new Map()\n const workflowModules = new Map()\n \n ").concat(d.map(function(e){return'modules.set("'.concat(e.hash,'", () => import(').concat(JSON.stringify(u.join(t,e.path)),"))")}).join("\n"),"\n\n ").concat(h.map(function(e){return'webhookModules.set("'.concat(e.id,'", () => import(').concat(JSON.stringify(u.join(n,e.path)),"))")}).join("\n"),"\n\n ").concat(b.map(function(e){return'eventModules.set("'.concat(e.id,'", () => import(').concat(JSON.stringify(u.join(o,e.path)),"))")}).join("\n"),"\n\n ").concat(rM(a.entries()).map(function(e){var t=rU(e,2),n=t[0],o=t[1];return"workflowModules.set(\n ".concat(JSON.stringify(n),",\n {\n ").concat(rM(Object.entries(o)).map(function(e){var t=rU(e,2),n=t[0],o=t[1];return o?"".concat(JSON.stringify(n),": {\n module: () => import(").concat(JSON.stringify(u.join(r,o.path)),"),\n export: ").concat(JSON.stringify(o.export),"\n },"):""}).join("\n"),"\n }\n )")}).join("\n"),'\n\n var stdin_default;\n var stdin_webhooks_default;\n var stdin_events_default;\n var stdin_workflow_block_handlers_default;\n\n function main() {\n stdin_default = async function(moduleHash, args) {\n const module = modules.get(moduleHash)\n\n if (!module) {\n throw new Error(`Module ${moduleHash} not found`)\n }\n\n const func = (await module()).default\n\n if (!func) {\n throw new Error(`Default export not found in module ${moduleHash}`)\n }\n\n if (typeof func !== "function") {\n throw new Error(`${moduleHash} does not export a function`)\n }\n\n return func(...args)\n }\n\n stdin_webhooks_default = async function(webhookModuleId, args) {\n const module = webhookModules.get(webhookModuleId)\n\n if (!module) {\n throw new Error(`Webhook handler not found: ${webhookModuleId}`)\n }\n\n const func = (await module()).default\n\n if (!func) {\n throw new Error(`Default export not found in module ${webhookModuleId}`)\n }\n\n if (typeof func !== "function") {\n throw new Error(`${webhookModuleId} does not export a function`)\n }\n\n return func(...args)\n }\n\n stdin_events_default = async function(eventModuleId, args) {\n const module = eventModules.get(eventModuleId)\n\n if (!module) {\n throw new Error("Event handler not found")\n }\n\n const func = (await module()).default\n\n if (!func) {\n throw new Error(`Default export not found in module ${eventModuleId}`)\n }\n\n if (typeof func !== "function") {\n throw new Error(`${eventModuleId} does not export a function`)\n }\n\n return func(...args)\n }\n\n stdin_workflow_block_handlers_default = async function(blockId, handler, args) {\n const modules = workflowModules.get(blockId)\n\n if (!modules) {\n throw new Error("Workflow block modules not found")\n }\n\n const handlerData = modules[handler]\n\n if (!handlerData) {\n throw new Error(`Workflow block module ${JSON.stringify(handler)} not found`)\n }\n\n if (handler === "schema") {\n const schema = (await handlerData.module())[handlerData.export]\n\n if (!schema) {\n throw new Error(`"${handler}" export not found in module ${JSON.stringify(blockId)}`)\n }\n\n return schema\n }\n\n const func = (await handlerData.module())[handlerData.export]\n\n if (!func) {\n throw new Error(`"${handler}" export not found in module ${JSON.stringify(blockId)}`)\n }\n\n if (typeof func !== "function") {\n throw new Error(`"${handler}" export in module ${JSON.stringify(blockId)} is not a function`)\n }\n\n return args ? func(...args) : func()\n }\n }\n\n main()\n\n'))]}})}).apply(this,arguments)}({appDirAbsolute:u.resolve(this._directories.app),srcDirAbsolute:u.resolve(this._directories.src),webhooksDirAbsolute:u.resolve(this._directories.webhooks),eventDirAbsolute:u.resolve(this._directories.events),workflowBlockModules:r})];case 1:if(O(t=l.sent()))return[2,t];if((n=t.value)===this._lastJs)return[3,5];l.label=2;case 2:return l.trys.push([2,4,,5]),[4,I.writeFile(this._tempFile.path,n)];case 3:return l.sent(),this._lastJs=n,[3,5];case 4:return o=l.sent(),[2,w({code:"FAILED_TO_CREATE_TEMP_FILE",path:this._tempFile.path,error:o})];case 5:return l.trys.push([5,7,,8]),[4,this._esbuildContext.rebuild()];case 6:return[2,m.apply(void 0,[l.sent()])];case 7:if(a=l.sent(),!(i=rx.safeParse(a)).success)return[2,w({code:"UNPARSABLE_BUILD_ERROR",error:a})];return[2,w({code:"BUILD_JAVASCRIPT_ERROR",errors:null!=(c=i.data.errors)?c:[],warnings:null!=(s=i.data.warnings)?s:[]})];case 8:return[2]}})}).apply(this,arguments)}},{key:"dispose",value:function(e){return rJ(function(){return rH(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,Promise.race([Promise.all([this._esbuildContext.dispose(),this._tempFile.cleanup()]),new Promise(function(r,t){return setTimeout(function(){return t(Error("Context disposal timeout"))},e)})])];case 1:return r.sent(),[3,3];case 2:return[2,w({code:"FAILED_TO_DISPOSE_OF_BUILD_CONTEXT",error:r.sent()})];case 3:return[2,m(void 0)]}})}).call(this)}}],r=[{key:"create",value:function(e){return rJ(function(e){var r,n,o,a,i;return rH(this,function(c){switch(c.label){case 0:r=e.outfile,n=e.directories,o=e.mode,c.label=1;case 1:return c.trys.push([1,4,,5]),[4,M.file({postfix:".js"})];case 2:var s,u;return[4,U((s=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(r){rK(e,r,t[r])})}return e}({},{entryPoints:[(a=c.sent()).path],bundle:!0,platform:"browser",format:"esm",plugins:[G({attio:{varName:"ATTIO_ROOT_SDK",type:"cjs"},"attio/server":{varName:"ATTIO_SERVER_APP_SDK",type:"cjs"}})]}),u=u={write:"write-to-disk"===o,outfile:r},Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(u)):(function(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(u)).forEach(function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(u,e))}),s))];case 3:return[2,m(new t({esbuildContext:c.sent(),tempFile:a,directories:n}))];case 4:return i=c.sent(),[2,w({code:"FAILED_TO_CREATE_ESBUILD_CONTEXT",outfile:r,error:i})];case 5:return[2]}})}).apply(this,arguments)}}],e&&rY(t.prototype,e),r&&rY(t,r),t}();function r$(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function rX(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){r$(a,n,o,i,c,"next",e)}function c(e){r$(a,n,o,i,c,"throw",e)}i(void 0)})}}function rz(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function rQ(e){return rX(function(){var r,t,n,o,a,i,c;return rz(this,function(s){switch(s.label){case 0:return r="src",t=u.join(r,"webhooks"),n=u.join(r,"events"),[4,v({client:rD.create({outfile:u.resolve("dist","index.js"),directories:{app:"",src:r},mode:e}),server:rq.create({outfile:u.resolve("dist","server.js"),directories:{app:"",src:r,webhooks:t,events:n},mode:e})})];case 1:if(O(o=s.sent()))return[2,o];return i=(a=o.value).client,c=a.server,[2,m({rebuild:function(){return rX(function(){var e,t;return rz(this,function(n){switch(n.label){case 0:var o,a;return[4,(o=r,(a=function(){var e,r,t,n;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(a){switch(a.label){case 0:return[4,eQ(o)];case 1:if(!(e=a.sent()))return[2,m(new Map)];return r=function(e){return D.readFileSync(e,"utf-8")},t=function(e){return D.existsSync(e)},n=new Map,[2,function(e,r,t){var n,o=new Map;try{var a=C(e,{range:!0,jsx:!0}),i=F(a,{sourceType:"module"}).acquire(a,!0);if(null===i)throw Error("Expected to be able to acquire module scope");L(a,null,{ExportNamedDeclaration:function(e,n){if(!e.declaration||"VariableDeclaration"!==e.declaration.type)throw Error("Expected export to be a variable declaration");if(1!==e.declaration.declarations.length)throw Error("Expected exactly one declaration per export");var a=e.declaration.declarations[0];if("Identifier"!==a.id.type||"app"!==a.id.name)throw Error("Expected export to be named 'app'");var c=a.init;if(!c||"ObjectExpression"!==c.type)throw Error("Expected app to be initialized to an object");var s=rg(c,"workflow",i);if((null==s?void 0:s.type)==="ObjectExpression"){var u=rg(s,"blocks",i);if((null==u?void 0:u.type)==="ObjectExpression"){var l=rg(u,"triggers",i);if((null==l?void 0:l.type)==="ArrayExpression"){var f=!0,p=!1,d=void 0;try{for(var h,b=l.elements[Symbol.iterator]();!(f=(h=b.next()).done);f=!0){var y=h.value;y&&rw(y,i,o,r,t)}}catch(e){p=!0,d=e}finally{try{f||null==b.return||b.return()}finally{if(p)throw d}}}var v=rg(u,"steps",i);if((null==v?void 0:v.type)==="ArrayExpression"){var m=!0,w=!1,g=void 0;try{for(var E,_=v.elements[Symbol.iterator]();!(m=(E=_.next()).done);m=!0){var O=E.value;O&&rw(O,i,o,r,t)}}catch(e){w=!0,g=e}finally{try{m||null==_.return||_.return()}finally{if(w)throw g}}}}}}})}catch(e){return w({code:"WORKFLOW_BLOCK_RESOLUTION_FAILED",message:(null!=(n=Error)&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):e instanceof n)?e.message:String(e)})}return m(o)}(e.content,e.path,{getModuleSource:r,doesModuleExist:t,modules:n})]}})},function(){var e=this,r=arguments;return new Promise(function(t,n){var o=a.apply(e,r);function i(e){rp(o,t,n,i,c,"next",e)}function c(e){rp(o,t,n,i,c,"throw",e)}i(void 0)})})())];case 1:if(O(e=n.sent()))return[2,e];return t=e.value,[2,v({client:i.rebuild({workflowBlockModules:t}),server:c.rebuild({workflowBlockModules:t})})]}})})()},dispose:function(e){return rX(function(){var r,t;return rz(this,function(n){switch(n.label){case 0:return[4,i.dispose(e)];case 1:return r=n.sent(),[4,c.dispose(e)];case 2:return t=n.sent(),[2,k(y([r,t]),function(){})]}})})()}})]}})})()}function rZ(e){switch(e.code){case"FAILED_TO_CREATE_TEMP_FILE":process.stderr.write("".concat(R.red("✖ "),"Failed to create temp file: ").concat(e.path,"\n"));break;case"FAILED_TO_GENERATE_CLIENT_ENTRY":process.stderr.write("".concat(R.red("✖ "),"Failed to generate client entry\n"));break;case"FAILED_TO_DISPOSE_OF_BUILD_CONTEXT":process.stderr.write("".concat(R.red("✖ "),"Failed to dispose of build context: ").concat(e.error,"\n"));break;case"FAILED_TO_CREATE_ESBUILD_CONTEXT":process.stderr.write("".concat(R.red("✖ "),"Failed to create esbuild context (").concat(e.outfile,"): ").concat(e.error,"\n"));break;case"ERROR_FINDING_SURFACE_EXPORTS":process.stderr.write("".concat(R.red("✖ "),"Failed to find surface exports: ").concat(e.error,"\n"));break;case"APP_ENTRY_POINT_NOT_FOUND":process.stderr.write("".concat(R.red("✖ "),"Could not find app.ts. See https://docs.attio.com/sdk/guides/app-ts-migration\n"));break;case"APP_EXPORT_NOT_FOUND":process.stderr.write("".concat(R.red("✖ "),'Could not find a named export "app" in ').concat(u.basename(e.path),". See https://docs.attio.com/sdk/guides/app-ts-migration\n"));break;case"UNPARSABLE_BUILD_ERROR":process.stderr.write("".concat(R.red("✖ "),"Failed to parse build error: ").concat(e.error,"\n"));break;case"ERROR_FINDING_SERVER_FUNCTION_MODULES":process.stderr.write("".concat(R.red("✖ "),"Failed to find server modules: ").concat(e.cause,"\n"));break;case"WORKFLOW_BLOCK_RESOLUTION_FAILED":process.stderr.write("".concat(R.red("✖ "),"Failed to build workflow block(s): ").concat(e.message,"\n"));break;default:return e}}function r0(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function r1(){var e;return(e=function(){var e,r,t,n;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(o){switch(o.label){case 0:return[4,rQ("write-to-disk")];case 1:if(O(e=o.sent()))return[2,e];return[4,(r=e.value).rebuild()];case 2:return t=o.sent(),[4,r.dispose(1e3)];case 3:if(O(n=o.sent()))return[2,n];if(O(t))return[2,t];return[2,m(!0)]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){r0(a,n,o,i,c,"next",e)}function c(e){r0(a,n,o,i,c,"throw",e)}i(void 0)})})()}function r2(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function r4(){var e;return(e=function(){var e,r,t;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,rs(u.resolve("tsconfig.json"))];case 1:if("Not a TypeScript project"===(e=n.sent()))return[2,m(!0)];return[4,ru(e)];case 2:if((r=n.sent()).length)return[2,w({code:"VALIDATE_TYPE_SCRIPT_ERROR",errors:r})];return[2,m(!0)];case 3:var o,a;if(o=t=n.sent(),null!=(a=Error)&&"undefined"!=typeof Symbol&&a[Symbol.hasInstance]?!!a[Symbol.hasInstance](o):o instanceof a)return[2,w({code:"VALIDATE_TYPE_SCRIPT_ERROR",errors:[rc.parse({text:t.message})]})];return[2,w({code:"FILE_SYSTEM_ERROR",error:t})];case 4:return[2]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){r2(a,n,o,i,c,"next",e)}function c(e){r2(a,n,o,i,c,"throw",e)}i(void 0)})})()}function r3(e,r,t){return(r3=r9()?Reflect.construct:function(e,r,t){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(e,n));return t&&r7(o,t.prototype),o}).apply(null,arguments)}function r6(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function r5(e){return(r5=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function r7(e,r){return(r7=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e})(e,r)}function r8(e){var r="function"==typeof Map?new Map:void 0;return(r8=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return r3(e,arguments,r5(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),r7(t,e)})(e)}function r9(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(r9=function(){return!!e})()}var te=function(e){"use strict";var r;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(e,r,n,o){var a,i,c;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");return i=t,c=[e],i=r5(i),r6(a=function(e,r){var t;if(r&&("object"==((t=r)&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t)||"function"==typeof r))return r;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,r9()?Reflect.construct(i,c||[],r5(this).constructor):i.apply(this,c)),"locations",void 0),r6(a,"source",void 0),r6(a,"filename",void 0),a.locations=r,a.source=n,a.filename=o,a}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r7(t,e),r=[{key:"toString",value:function(){var e=this.locations[0],r=e.line,t=e.column;return"".concat(this.message,"\n\n").concat(this.filename,":").concat(this.locations[0].line,"\n\n").concat(X(this.source,{start:{line:r,column:t}}),"\n")}}],function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,r),t}(r8(Error));function tr(e,r){for(var t=1,n=1,o=0;o<r.start;o++)"\n"===e[o]?(t++,n=1):n++;return{line:t,column:n}}function tt(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function tn(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function to(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){tn(a,n,o,i,c,"next",e)}function c(e){tn(a,n,o,i,c,"throw",e)}i(void 0)})}}function ta(e){return function(e){if(Array.isArray(e))return tt(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||ti(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ti(e,r){if(e){if("string"==typeof e)return tt(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return tt(e,r)}}function tc(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function ts(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function tu(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function tl(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function tf(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){tl(a,n,o,i,c,"next",e)}function c(e){tl(a,n,o,i,c,"throw",e)}i(void 0)})}}function tp(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):e instanceof r}function td(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function th(){return tf(function(){var e,r;return td(this,function(n){var o,a,i;switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,(o=["schema.graphql"],(a=function(){var e,r,t;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:e=process.cwd(),n.label=1;case 1:if("/"===e)return[3,6];t=(r=u).join.apply(r,[e,"node_modules","attio"].concat(function(e){if(Array.isArray(e))return ts(e)}(o)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||function(e,r){if(e){if("string"==typeof e)return ts(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ts(e,r)}}(o)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())),n.label=2;case 2:return n.trys.push([2,4,,5]),[4,c.access(t)];case 3:return n.sent(),[2,t];case 4:return n.sent(),[3,5];case 5:return e=u.dirname(e),[3,1];case 6:return[2,null]}})},function(){var e=this,r=arguments;return new Promise(function(t,n){var o=a.apply(e,r);function i(e){tu(o,t,n,i,c,"next",e)}function c(e){tu(o,t,n,i,c,"throw",e)}i(void 0)})})())];case 1:return(e=n.sent())||e1("No schema.graphql found in node_modules. Did you run `npm install`?"),[4,(i=H(s(e,"utf8")),to(function(){return tc(this,function(e){switch(e.label){case 0:return[4,Promise.all((function e(r){var n=[],o=t.readdirSync(r,{withFileTypes:!0}),a=!0,i=!1,c=void 0;try{for(var s,l=o[Symbol.iterator]();!(a=(s=l.next()).done);a=!0){var f=s.value,p=u.join(r,f.name);f.isDirectory()?n.push.apply(n,ta(e(p))):f.isFile()&&".graphql.d.ts"===u.extname(f.name)&&n.push(p)}}catch(e){i=!0,c=e}finally{try{a||null==l.return||l.return()}finally{if(i)throw c}}return n})(".").map(function(e){return to(function(){return tc(this,function(r){return[2,t.promises.unlink(e)]})})()}))];case 1:return e.sent(),[4,Promise.all((function e(r){var n=[],o=t.readdirSync(r,{withFileTypes:!0}),a=!0,i=!1,c=void 0;try{for(var s,l=o[Symbol.iterator]();!(a=(s=l.next()).done);a=!0){var f=s.value,p=u.join(r,f.name);(!f.isDirectory()||"node_modules"!==f.name)&&(f.isDirectory()?n.push.apply(n,ta(e(p))):f.isFile()&&(".graphql"===u.extname(f.name)||".gql"===u.extname(f.name))&&n.push(p))}}catch(e){i=!0,c=e}finally{try{a||null==l.return||l.return()}finally{if(i)throw c}}return n})(".").map(function(e){return to(function(){var r,n,o;return tc(this,function(a){switch(a.label){case 0:return r=t.readFileSync(e,"utf-8"),[4,to(function(){var t,n,o,a,c,s,l,f,p,d,h,b,y,v,m,w,g,E,_,O;return tc(this,function(k){switch(k.label){case 0:o={};try{o=H(r)}catch(t){if(t.message.startsWith("Syntax Error: Unexpected Name"))throw new te(t.message,t.locations,r,e)}if(null==(t=o.definitions)||t.forEach(function(t){if(t&&t.kind===W.OPERATION_DEFINITION){var n=t.loc;if(!n)throw Error("Expected a location");switch(t.operation){case J.MUTATION:throw new te("Mutations are not supported",[tr(r,n)],r,e);case J.SUBSCRIPTION:throw new te("Subscriptions are not supported",[tr(r,n)],r,e);case J.QUERY:break;default:return t.operation}}}),(c=null!=(a=null==(n=o.definitions)?void 0:n.filter(function(e){return e&&e.kind===W.OPERATION_DEFINITION&&K(e)&&e.operation===J.QUERY}))?a:[]).length>1){if(!(l=null==(s=c[1])?void 0:s.loc))throw Error("Expected a location");throw new te("Only one query is allowed per .graphql file",[tr(r,l)],r,e)}if(!c.length)throw new te("No query found.",[{line:1,column:1}],r,e);switch((f=c[0]).kind){case W.OPERATION_DEFINITION:return[3,1];case W.FRAGMENT_DEFINITION:case W.SCHEMA_DEFINITION:case W.SCALAR_TYPE_DEFINITION:case W.OBJECT_TYPE_DEFINITION:case W.INTERFACE_TYPE_DEFINITION:case W.UNION_TYPE_DEFINITION:case W.ENUM_TYPE_DEFINITION:case W.INPUT_OBJECT_TYPE_DEFINITION:case W.DIRECTIVE_DEFINITION:case W.SCHEMA_EXTENSION:case W.SCALAR_TYPE_EXTENSION:case W.OBJECT_TYPE_EXTENSION:case W.INTERFACE_TYPE_EXTENSION:case W.UNION_TYPE_EXTENSION:case W.ENUM_TYPE_EXTENSION:case W.INPUT_OBJECT_TYPE_EXTENSION:return[3,6]}return[3,7];case 1:b=(h=null!=(d=K(f)&&f.kind===W.OPERATION_DEFINITION?null==(p=f.name)?void 0:p.value:void 0)?d:"")?h.charAt(0).toUpperCase()+h.slice(1):"Unnamed_1_",y="",k.label=2;case 2:return k.trys.push([2,4,,5]),[4,q({documents:[{document:o}],config:{},filename:"relative/pathTo/filename.ts",schema:i,plugins:[{"typescript-operations":{avoidOptionals:!0,enumsAsTypes:!0}}],pluginMap:{"typescript-operations":eb}})];case 3:return y=k.sent(),[3,5];case 4:if((v=k.sent()).message.startsWith("GraphQL Document Validation failed with")&&(m=v.message.match(/Error 0: (.+)\n\s+at GraphQL request:(\d+):(\d+)/))){var S;throw g=(w=function(e){if(Array.isArray(e))return e}(S=m)||function(e,r){var t,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(t=o.next()).done)&&(a.push(t.value),a.length!==r);i=!0);}catch(e){c=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw n}}return a}}(S,4)||ti(S,4)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[1],E=w[2],_=w[3],new te(g,[{line:parseInt(E),column:parseInt(_)}],r,e)}if(v.message.startsWith("Unable to find root schema type for"))throw new te(v.message,[{line:1,column:1}],r,e);throw v;case 5:return[2,$('\n declare module "./'.concat(u.basename(e),'" {\n ').concat(y.replace(/__typename\?: '[^']+',\s*/g,""),"\n const value: Query<").concat(b,"QueryVariables, ").concat(b,"Query>\n export default value\n}\n "),{parser:"typescript"})];case 6:if(!(O=f.loc))throw Error("Expected a location");throw new te("File should contain only a single query",[tr(r,O)],r,e);case 7:return[2,f];case 8:return[2]}})})()];case 1:return n=a.sent(),[4,$('/**\n * ****************************************************\n * THIS FILE IS AUTO-GENERATED AT DEVELOPMENT TIME.\n *\n * DO NOT EDIT DIRECTLY OR COMMIT IT TO SOURCE CONTROL.\n * ****************************************************\n */\nimport {Query} from "attio/client"\n\ntype Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };\n\ntype Scalars = {\n ID: { input: string; output: string };\n String: { input: string; output: string };\n Boolean: { input: boolean; output: boolean };\n Int: { input: number; output: number };\n Float: { input: number; output: number };\n};\n\n'.concat(n,"\n"),{parser:"typescript"})];case 2:return o=a.sent(),[4,t.promises.writeFile("".concat(e,".d.ts"),o)];case 3:return a.sent(),[2]}})})()}))];case 2:return e.sent(),[2]}})})())];case 2:return n.sent(),[2,m(!0)];case 3:if(tp(r=n.sent(),te))return[2,w({code:"GRAPHQL_ERROR",error:r})];return[2,w({code:"GRAPHQL_CODEGEN_ERROR",error:tp(r,Error)?r.message:"GraphQL code generation failed"})];case 4:return[2]}})})()}function tb(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var ty=new d("build").description("Build your Attio extension locally").action(function(){var e;return(e=function(){var e,r,t,n,o,a;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:return[4,e0()];case 1:return O(i.sent())&&e2(),[4,rr("Generating GraphQL types...","GraphQL types generated successfully",th)];case 2:return O(e=i.sent())&&e1(e.error.error.toString()),[4,e5()];case 3:return O(i.sent())&&e1("Failed to generate settings types"),[4,rr("Validating TypeScript...","TypeScript validation passed",r4)];case 4:if(O(r=i.sent()))switch(r.error.code){case"VALIDATE_TYPE_SCRIPT_ERROR":r.error.errors.forEach(rl),process.stderr.write("TypeScript validation failed"),process.exit(1);case"FILE_SYSTEM_ERROR":process.stderr.write("TypeScript validation failed due to a file system error: ".concat(r.error.error)),process.exit(1)}return[4,rr("Building JavaScript...","JavaScript build completed successfully",r1)];case 5:return O(t=i.sent())&&("BUILD_JAVASCRIPT_ERROR"===t.error.code?(o=(n=t.error).errors,a=n.warnings,null==o||o.forEach(function(e){return rf(e,"error")}),null==a||a.forEach(function(e){return rf(e,"warning")}),process.stderr.write("JavaScript build failed")):(rZ(t.error),process.stderr.write("Build context error")),process.exit(1)),[2]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){tb(a,n,o,i,c,"next",e)}function c(e){tb(a,n,o,i,c,"throw",e)}i(void 0)})})()}),tv="development"===process.env.NODE_ENV,tm="attio.".concat(tv?"me":"com"),tw="https://build.".concat(tm,"/api"),tg="https://".concat("app.".concat(tm)),tE="2026-02-23";function t_(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function tO(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){t_(a,n,o,i,c,"next",e)}function c(e){t_(a,n,o,i,c,"throw",e)}i(void 0)})}}function tk(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):e instanceof r}function tS(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(r){var n;n=t[r],r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n})}return e}function tI(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):(function(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}function tT(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var tx=b.object({message:b.string()}),tA=function(){"use strict";var e;function r(){if(!(this instanceof r))throw TypeError("Cannot call a class as a function")}return e=[{key:"_fetch",value:function(e){return tO(function(e){var r,t,n,o,a,i,c,s,u,l,f,p,d;return tT(this,function(h){switch(h.label){case 0:if(r=e.path,t=e.fetchOptions,n=e.schema,"Authenticated"!==e.authenticated)return[3,2];return[4,np.ensureAuthed()];case 1:return a=h.sent(),[3,3];case 2:a=m(null),h.label=3;case 3:if(O(o=a))return[2,w({code:"UNAUTHORIZED",error:o.error})];i=o.value,h.label=4;case 4:return h.trys.push([4,9,,10]),[4,fetch(r.startsWith("https")?r:"".concat(tw).concat(r),tI(tS({},t),{headers:tS(tI(tS({"x-attio-platform":"developer-cli"},i?{Authorization:"Bearer ".concat(i)}:{}),{"Content-Type":"application/json"}),t.headers)}))];case 5:if((c=h.sent()).ok)return[3,7];return l=(u=this)._parseErrorResponseMessage,[4,c.text()];case 6:return s=l.apply(u,[h.sent()]),[2,w({code:"HTTP_ERROR",status:c.status,message:s})];case 7:return[4,c.json()];case 8:if(f=h.sent(),!(p=n.safeParse(f)).success)return[2,w({code:"INVALID_RESPONSE",message:p.error.message})];return[2,m(p.data)];case 9:return[2,w({code:"NETWORK_ERROR",message:tk(d=h.sent(),Error)?d.message:String(d)})];case 10:return[2]}})}).apply(this,arguments)}},{key:"_parseErrorResponseMessage",value:function(e){try{return tx.parse(JSON.parse(e)).message}catch(r){return e}}},{key:"get",value:function(e){return tO(function(e){var r,t,n,o,a,i;return tT(this,function(c){return r=e.path,t=e.schema,o=void 0===(n=e.headers)?{}:n,i=void 0===(a=e.authenticated)?"Authenticated":a,[2,this._fetch({path:r,fetchOptions:{method:"GET",headers:o},schema:t,authenticated:i})]})}).apply(this,arguments)}},{key:"post",value:function(e){return tO(function(e){var r,t,n,o,a,i,c;return tT(this,function(s){return r=e.path,t=e.body,n=e.schema,a=void 0===(o=e.headers)?{}:o,c=void 0===(i=e.authenticated)?"Authenticated":i,[2,this._fetch({path:r,fetchOptions:{method:"POST",body:tk(t,URLSearchParams)?t.toString():JSON.stringify(t),headers:tS({"Content-Type":tk(t,URLSearchParams)?"application/x-www-form-urlencoded":"application/json"},a)},schema:n,authenticated:c})]})}).apply(this,arguments)}}],function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,e),r}(),tR=b.object({user:b.object({id:b.string(),email_address:b.string(),name:b.object({full:b.string()})})}),tj=b.object({workspace_id:b.string().uuid(),slug:b.string(),name:b.string(),logo_url:b.string().nullable()}),tP=[tj.parse({workspace_id:"a85e3bcf-a9a2-4df9-9e92-e708bf98d238",slug:"test-slug",name:"Test Workspace",logo_url:null})],tN=b.object({workspaces:b.array(tj)}),tD=b.object({app_id:b.string().uuid(),major:b.number(),minor:b.number(),app_prod_version_bundle_id:b.string(),client_bundle_upload_url:b.string(),server_bundle_upload_url:b.string()}),tC=b.object({app:b.object({app_id:b.string().uuid(),title:b.string()})}),tF=tC.parse({app:{app_id:"0cbafb09-2ef7-473c-a048-08a5d190a395",title:"Test App"}}),tL=b.object({success:b.literal(!0)}),tU=b.object({app_dev_version_id:b.string().uuid(),app_dev_version_bundle_id:b.string().uuid(),client_bundle_upload_url:b.string().url(),server_bundle_upload_url:b.string().url()}),tM=b.object({app_id:b.string().uuid(),app_dev_version_id:b.string()}),tG=b.object({app_id:b.string().uuid(),workspace_id:b.string()}),tB=b.object({major:b.number(),minor:b.number(),created_at:b.string(),released_at:b.string().nullable().optional(),is_published:b.boolean(),num_installations:b.number(),publication_status:b.enum(["private","in-review","published","rejected"])}),tV=b.object({app_prod_versions:b.array(tB)}),tW=b.object({access_token:b.string(),token_type:b.literal("Bearer"),refresh_token:b.string(),expires_in:b.number()}),tJ=b.object({capability:b.string(),clientId:b.string().optional(),expires:b.number(),issued:b.number(),token:b.string()});function tY(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function tK(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){tY(a,n,o,i,c,"next",e)}function c(e){tY(a,n,o,i,c,"throw",e)}i(void 0)})}}function tH(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var tq=new(function(){"use strict";var e;function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");t=void 0,(e="_fetcher")in this?Object.defineProperty(this,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):this[e]=t,this._fetcher=new tA}return e=[{key:"whoami",value:function(){return tK(function(){var e;return tH(this,function(r){switch(r.label){case 0:return[4,this._fetcher.get({path:"".concat(tg,"/api/auth/whoami"),schema:tR})];case 1:if(O(e=r.sent()))return[2,w({code:"WHOAMI_ERROR",error:e.error})];return[2,m(e.value.user)]}})}).call(this)}},{key:"fetchWorkspaces",value:function(){return tK(function(){var e;return tH(this,function(r){switch(r.label){case 0:if("test"===process.env.NODE_ENV)return[2,m(tP)];return[4,this._fetcher.get({path:"/dev-workspaces",schema:tN})];case 1:if(O(e=r.sent()))return[2,w({code:"FETCH_WORKSPACES_ERROR",error:e.error})];return[2,m(e.value.workspaces)]}})}).call(this)}},{key:"createVersion",value:function(e){return tK(function(e){var r,t,n,o;return tH(this,function(a){switch(a.label){case 0:return r=e.appId,t=e.major,n=e.cliVersion,[4,this._fetcher.post({path:"/apps/".concat(r,"/prod-versions"),body:{major:t,cli_version:n,sdk_version:tE},schema:tD})];case 1:if(O(o=a.sent()))return[2,w({code:"CREATE_VERSION_ERROR",error:o.error})];return[2,o]}})}).apply(this,arguments)}},{key:"fetchAppInfo",value:function(e){return tK(function(){var r;return tH(this,function(t){switch(t.label){case 0:if("test"===process.env.NODE_ENV)return[2,m(tF.app)];return[4,this._fetcher.get({path:"/apps/by-slug/".concat(e),schema:tC})];case 1:if(O(r=t.sent())){if("HTTP_ERROR"===r.error.code&&404===r.error.status)return[2,w({code:"APP_NOT_FOUND"})];return[2,w({code:"FETCH_APP_INFO_ERROR",error:r.error})]}return[2,m(r.value.app)]}})}).call(this)}},{key:"completeBundleUpload",value:function(e){return tK(function(e){var r,t,n,o;return tH(this,function(a){switch(a.label){case 0:return r=e.appId,t=e.devVersionId,n=e.bundleId,[4,this._fetcher.post({path:"/apps/".concat(r,"/dev-versions/").concat(t,"/bundles/").concat(n,"/complete"),body:{},schema:tL})];case 1:if(O(o=a.sent()))return[2,w({code:"COMPLETE_BUNDLE_UPLOAD_ERROR",error:o.error})];return[2,m(void 0)]}})}).apply(this,arguments)}},{key:"completeProdBundleUpload",value:function(e){return tK(function(e){var r,t,n,o,a;return tH(this,function(i){switch(i.label){case 0:return r=e.appId,t=e.bundleId,n=e.major,o=e.minor,[4,this._fetcher.post({path:"/apps/".concat(r,"/prod-versions/").concat(n,"/").concat(o,"/bundles/").concat(t,"/complete"),body:{},schema:tL})];case 1:if(O(a=i.sent()))return[2,w({code:"COMPLETE_PROD_BUNDLE_UPLOAD_ERROR",error:a.error})];return[2,m(void 0)]}})}).apply(this,arguments)}},{key:"startUpload",value:function(e){return tK(function(e){var r,t,n;return tH(this,function(o){switch(o.label){case 0:return r=e.appId,t=e.devVersionId,[4,this._fetcher.post({path:"/apps/".concat(r,"/dev-versions/").concat(t,"/bundles"),body:{sdk_version:tE},schema:tU})];case 1:if(O(n=o.sent()))return[2,w({code:"START_UPLOAD_ERROR",error:n.error})];return[2,n]}})}).apply(this,arguments)}},{key:"createDevVersion",value:function(e){return tK(function(e){var r,t,n,o,a;return tH(this,function(i){switch(i.label){case 0:return r=e.appId,t=e.cliVersion,n=e.targetWorkspaceId,o=e.environmentVariables,[4,this._fetcher.post({path:"/apps/".concat(r,"/dev-versions"),body:{major:1,target_workspace_id:n,environment_variables:o,cli_version:t},schema:tM})];case 1:if(O(a=i.sent()))return[2,w({code:"CREATE_DEV_VERSION_ERROR",error:a.error})];return[2,a]}})}).apply(this,arguments)}},{key:"fetchInstallation",value:function(e){return tK(function(e){var r,t,n;return tH(this,function(o){switch(o.label){case 0:return r=e.appId,t=e.workspaceId,[4,this._fetcher.get({path:"/apps/".concat(r,"/workspace/").concat(t,"/dev-installation"),schema:tG})];case 1:if(O(n=o.sent())){if("HTTP_ERROR"===n.error.code&&404===n.error.status)return[2,m(null)];return[2,w({code:"FETCH_INSTALLATION_ERROR",error:n.error})]}return[2,n]}})}).apply(this,arguments)}},{key:"fetchVersions",value:function(e){return tK(function(){var r;return tH(this,function(t){switch(t.label){case 0:return[4,this._fetcher.get({path:"/apps/".concat(e,"/prod-versions"),schema:tV})];case 1:if(O(r=t.sent()))return[2,w({code:"FETCH_VERSIONS_ERROR",error:r.error})];return[2,m(r.value.app_prod_versions)]}})}).call(this)}},{key:"exchangeToken",value:function(e){return tK(function(e){var r,t,n,o,a,i;return tH(this,function(c){switch(c.label){case 0:return r=e.receivedCode,t=e.verifierString,n=e.redirectUri,o=e.clientId,(a=new URLSearchParams).append("grant_type","authorization_code"),a.append("code",r),a.append("client_id",o),a.append("redirect_uri",n),a.append("code_verifier",t),[4,this._fetcher.post({path:"".concat(tg,"/oidc/token"),body:a,schema:tW,authenticated:"Not Authenticated"})];case 1:if(O(i=c.sent()))return[2,w({code:"GET_TOKEN_ERROR",error:i.error})];return[2,i]}})}).apply(this,arguments)}},{key:"refreshToken",value:function(e){return tK(function(e){var r,t,n,o;return tH(this,function(a){switch(a.label){case 0:return r=e.refreshToken,t=e.clientId,(n=new URLSearchParams).append("grant_type","refresh_token"),n.append("refresh_token",r),n.append("client_id",t),[4,this._fetcher.post({path:"".concat(tg,"/oidc/token"),body:n,schema:tW})];case 1:if(O(o=a.sent()))return[2,w({code:"REFRESH_TOKEN_ERROR",error:o.error})];return[2,o]}})}).apply(this,arguments)}},{key:"authenticateAbly",value:function(e){return tK(function(){var r;return tH(this,function(t){switch(t.label){case 0:return[4,this._fetcher.post({path:"/integrations/ably/auth",body:{token_params:e},schema:tJ})];case 1:if(O(r=t.sent()))return[2,w({code:"ABLY_AUTHENTICATION_ERROR",message:"message"in r.error?r.error.message:r.error.code})];return[2,r]}})}).call(this)}}],function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,e),r}());function t$(e,r){var t=r.error;switch(process.stderr.write("".concat(R.red("✖ ")).concat(e,"\n")),t.code){case"HTTP_ERROR":process.stderr.write("HTTP Error (".concat(t.status,"): ").concat(t.message,"\n"));break;case"INVALID_RESPONSE":process.stderr.write("Invalid response: ".concat(t.message,"\n"));break;case"NETWORK_ERROR":process.stderr.write("Network error: ".concat(t.message,"\n"));break;case"UNAUTHORIZED":process.stderr.write('Unauthorized. You must log in with "attio login"\n')}}function tX(e){switch(e.code){case"APP_NOT_FOUND":var r="development"===process.env.NODE_ENV?"https://build.attio.me":"https://build.attio.com";process.stderr.write("\n".concat(R.red("✖ "),"App not found. Did you create it in the developer portal at ").concat(r,"?\n"));break;case"FETCH_APP_INFO_ERROR":t$("Error loading app info",{error:e.error});break;default:return e}}function tz(e){var r=e.code,t=e.error;switch(r){case"MALFORMED_PACKAGE_JSON":t.issues.length>0?process.stderr.write("".concat(R.red("✖ "),"Malformed package.json: ").concat(t.issues[0].message,"\n")):process.stderr.write("".concat(R.red("✖ "),"Malformed package.json: ").concat(t.message,"\n"));break;case"FILE_SYSTEM_ERROR":process.stderr.write("".concat(R.red("✖ "),"Failed to read package.json\n"));break;case"INVALID_JSON":process.stderr.write("".concat(R.red("✖ "),"Invalid JSON in package.json: ").concat(t,"\n"))}}function tQ(e){var r=e.error;switch(r.code){case"UNABLE_TO_FIND_PACKAGE_JSON":process.stderr.write("".concat(R.red("✖ "),"Failed to find package.json in ").concat(r.path,"\n"));break;case"UNABLE_TO_READ_PACKAGE_JSON":process.stderr.write("".concat(R.red("✖ "),"Failed to read package.json: ").concat(r.error,"\n"));break;case"UNABLE_TO_PARSE_PACKAGE_JSON":process.stderr.write("".concat(R.red("✖ "),"Failed to parse package.json: ").concat(r.error,"\n"));break;case"INVALID_PACKAGE_JSON":process.stderr.write("".concat(R.red("✖ "),"Invalid package.json: ").concat(r.error,"\n"));break;case"ERROR_LOADING_PACKAGE_JSON":process.stderr.write("".concat(R.red("✖ "),"Error loading package.json: ").concat(r.error,"\n"));break;case"NO_CLI_VERSION_FOUND":process.stderr.write("".concat(R.red("✖ "),"No CLI version found in attio's package.json\n"));break;default:return r}}function tZ(e){switch(e.code){case"FETCH_WORKSPACES_ERROR":process.stderr.write("Error fetching workspaces: ".concat(e.error,"\n\n").concat(tg,"/welcome/workspace-details\n "));break;case"NO_WORKSPACE_FOUND":process.stderr.write('You are not the admin any workspace with the slug "'.concat(e.workspace_slug,'". Either request permission from "').concat(e.workspace_slug,'" or create your own.\n\n').concat(tg,"/welcome/workspace-details\n "));break;case"NO_WORKSPACES_FOUND":process.stderr.write("You are not the admin of any workspaces. Either request permission from an existing workspace or create your own.\n\n".concat(tg,"/welcome/workspace-details\n "));break;default:return e}}function t0(e){switch(e.code){case"SAVE_KEYCHAIN_ERROR":process.stderr.write(R.red("Error saving token to keychain: ".concat(e.error)));break;case"LOAD_KEYCHAIN_ERROR":process.stderr.write(R.red("Error loading token from keychain: ".concat(e.error)));break;case"DELETE_KEYCHAIN_ERROR":process.stderr.write(R.red("Error deleting token from keychain: ".concat(e.error)));break;default:return e}}function t1(e){if("FAILED_TO_CONNECT_TO_LOGS_SERVER"!==e.code)return e.code;var r,t,n="Failed to connect to logs server";r=e.error,(null!=(t=Error)&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](r):r instanceof t)&&(n="".concat(n,": ").concat(e.error.message)),process.stderr.write(R.red("\n".concat(n,"\n")))}function t2(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function t4(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){t2(a,n,o,i,c,"next",e)}function c(e){t2(a,n,o,i,c,"throw",e)}i(void 0)})}}function t3(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function t6(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;return t4(function(){var t;return t3(this,function(n){switch(n.label){case 0:t=e,n.label=1;case 1:var o;if(!(t<e+r))return[3,4];return[4,(o=t,t4(function(){return t3(this,function(e){return[2,new Promise(function(e){var r=en.createConnection(o,"127.0.0.1");r.setTimeout(1e3);var t=function(){r.removeAllListeners(),r.destroy()};r.once("error",function(r){t(),"ECONNREFUSED"===r.code?e(!0):e(!1)}),r.once("connect",function(){t(),e(!1)}),r.once("timeout",function(){t(),e(!1)})})]})})())];case 2:if(n.sent())return[2,t];n.label=3;case 3:return t++,[3,1];case 4:return e1("Could not find an available port after ".concat(r," attempts")),[2]}})})()}function t5(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function t7(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){t5(a,n,o,i,c,"next",e)}function c(e){t5(a,n,o,i,c,"throw",e)}i(void 0)})}}function t8(e,r){if(!(e instanceof r))throw TypeError("Cannot call a class as a function")}function t9(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function ne(e,r,t){return r&&t9(e.prototype,r),t&&t9(e,t),e}function nr(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function nt(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var nn=b.object({access_token:b.string(),refresh_token:b.string(),token_type:b.literal("Bearer"),expires_at:b.number()}),no=function(){"use strict";function e(){t8(this,e),nr(this,"SERVICE_NAME","attio-cli"),nr(this,"ACCOUNT_NAME","developer"),nr(this,"keytarPromise",void 0),this.keytarPromise=eE.e("137").then(eE.bind(eE,360)).then(function(e){return e.default})}return ne(e,[{key:"save",value:function(e){return t7(function(){var r;return nt(this,function(t){switch(t.label){case 0:return[4,this.keytarPromise];case 1:r=t.sent(),t.label=2;case 2:return t.trys.push([2,4,,5]),[4,r.setPassword(this.SERVICE_NAME,this.ACCOUNT_NAME,JSON.stringify(e))];case 3:return t.sent(),[2,m(void 0)];case 4:return[2,w({code:"SAVE_KEYCHAIN_ERROR",error:t.sent()})];case 5:return[2]}})}).call(this)}},{key:"load",value:function(){return t7(function(){var e,r,t,n,o,a,i;return nt(this,function(c){switch(c.label){case 0:return[4,this.keytarPromise];case 1:e=c.sent(),r=null,c.label=2;case 2:return c.trys.push([2,4,,5]),[4,e.getPassword(this.SERVICE_NAME,this.ACCOUNT_NAME)];case 3:return r=c.sent(),[3,5];case 4:return[2,w({code:"LOAD_KEYCHAIN_ERROR",error:c.sent()})];case 5:if(null===r)return[2,m(null)];c.label=6;case 6:return c.trys.push([6,7,,9]),t=JSON.parse(r),[3,9];case 7:return c.sent(),[4,this.delete()];case 8:if(O(n=c.sent()))return[2,w({code:"LOAD_KEYCHAIN_ERROR",error:n.error})];return console.debug("Wiped keychain entry due to invalid JSON"),[2,m(null)];case 9:if((o=nn.safeParse(t)).success)return[3,11];return[4,this.delete()];case 10:if(O(a=c.sent()))return[2,w({code:"LOAD_KEYCHAIN_ERROR",error:a.error})];return console.debug("Wiped keychain entry due to schema mismatch"),[2,m(null)];case 11:if(!(o.data.expires_at<Date.now()+3e5))return[3,13];return[4,this.delete()];case 12:if(O(i=c.sent()))return[2,w({code:"LOAD_KEYCHAIN_ERROR",error:i.error})];return[2,m(null)];case 13:return[2,m(o.data)]}})}).call(this)}},{key:"delete",value:function(){return t7(function(){var e;return nt(this,function(r){switch(r.label){case 0:return[4,this.keytarPromise];case 1:e=r.sent(),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,e.deletePassword(this.SERVICE_NAME,this.ACCOUNT_NAME)];case 3:return r.sent(),[2,m(void 0)];case 4:return[2,w({code:"DELETE_KEYCHAIN_ERROR",error:r.sent()})];case 5:return[2]}})}).call(this)}}]),e}(),na=function(){"use strict";function e(){t8(this,e),nr(this,"TEST_TOKEN",{access_token:"TEST",refresh_token:"TEST",token_type:"Bearer",expires_at:Number.MAX_SAFE_INTEGER})}return ne(e,[{key:"save",value:function(e){return t7(function(){return nt(this,function(e){return[2,m(void 0)]})})()}},{key:"load",value:function(){return t7(function(){return nt(this,function(e){return[2,m(this.TEST_TOKEN)]})}).call(this)}},{key:"delete",value:function(){return t7(function(){return nt(this,function(e){return[2,m(void 0)]})})()}}]),e}(),ni=null,nc=function(){return null===ni&&(ni="test"===process.env.NODE_ENV?new na:new no),ni};function ns(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nu(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){ns(a,n,o,i,c,"next",e)}function c(e){ns(a,n,o,i,c,"throw",e)}i(void 0)})}}function nl(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function nf(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var np=new(function(){"use strict";var e;function r(){if(!(this instanceof r))throw TypeError("Cannot call a class as a function");nl(this,"clientId","f881c6f1-82d7-48a5-a581-649596167845"),nl(this,"isRefreshingToken",!1),nl(this,"refreshTimeout",null)}return e=[{key:"ensureAuthed",value:function(){return nu(function(){var e,r;return nf(this,function(t){switch(t.label){case 0:return[4,nc().load()];case 1:if(O(e=t.sent())||null===(r=e.value)||r.expires_at<Date.now())return[2,this.promptToAuthenticate()];return this.scheduleRefresh(r),[2,m(r.access_token)]}})}).call(this)}},{key:"promptToAuthenticate",value:function(){return nu(function(){return nf(this,function(e){switch(e.label){case 0:if("test"===process.env.NODE_ENV)return[3,2];return process.stdout.write("You need to log in with Attio. Press Enter to continue...\n\n"),[4,new Promise(function(e){return process.stdin.once("data",e)})];case 1:e.sent(),e.label=2;case 2:return[2,this.authenticate()]}})}).call(this)}},{key:"authenticate",value:function(){return nu(function(){var e,r,t,n,o,a,i,c,s,u,l,f,p,d,h,b,y;return nf(this,function(v){switch(v.label){case 0:return e=this,[4,nc().load()];case 1:if(O(r=v.sent()))return[2,r];if(null!==(t=r.value)&&t.expires_at>Date.now())return[2,m(t.access_token)];return n=Z(32).toString("base64url"),o=Q("sha256").update(n,"utf8").digest().toString("base64url"),a=Z(32).toString("base64url"),[4,t6(3e3,65e3)];case 2:i=v.sent(),c="http://localhost:".concat(i),u=new Promise(function(e){s=e}),(l=new er).get("/",function(r){return nu(function(){var e,t,o;return nf(this,function(i){switch(i.label){case 0:return t=(e=r.req.query()).code,e.state!==a&&s(w({code:"OAUTH_STATE_MISMATCH"})),t||s(w({code:"NO_AUTHORIZATION_CODE"})),[4,tq.exchangeToken({receivedCode:t,verifierString:n,redirectUri:c,clientId:this.clientId})];case 1:return o=i.sent(),setTimeout(function(){f.close(),s(o)},1e3),[2,r.html("\n <html>\n <body>\n <script>window.location.href = '".concat(tg,"/authorized';<\/script>\n </body>\n </html>\n "))]}})}).call(e)}),f=ee({fetch:l.fetch,port:i}),v.label=3;case 3:return v.trys.push([3,,7,8]),(p=new URL("".concat(tg,"/oidc/authorize"))).searchParams.append("scope","openid offline_access"),p.searchParams.append("response_type","code"),p.searchParams.append("client_id",this.clientId),p.searchParams.append("redirect_uri",c),p.searchParams.append("state",a),p.searchParams.append("code_challenge",o),p.searchParams.append("code_challenge_method","S256"),[4,et(p.toString())];case 4:return v.sent(),[4,u];case 5:if(O(d=v.sent()))return[2,d];return h=d.value,process.stdout.write("\uD83D\uDD11 Saving new token to keychain\n"),b={access_token:h.access_token,refresh_token:h.refresh_token,token_type:h.token_type,expires_at:Date.now()+1e3*h.expires_in},[4,nc().save(b)];case 6:if(O(y=v.sent()))return[2,y];return this.scheduleRefresh(b),[2,m(h.access_token)];case 7:return f.close(),[7];case 8:return[2]}})}).call(this)}},{key:"scheduleRefresh",value:function(e){var r=this;null!==this.refreshTimeout&&clearTimeout(this.refreshTimeout);var t=Math.min(Math.max(0,(e.expires_at-Date.now())/10),0x7fffffff);this.refreshTimeout=setTimeout(function(){return nu(function(){return nf(this,function(r){switch(r.label){case 0:if(this.isRefreshingToken)return[2];this.isRefreshingToken=!0,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this.refreshToken(e)];case 2:return r.sent(),[3,4];case 3:return this.isRefreshingToken=!1,this.refreshTimeout=null,[7];case 4:return[2]}})}).call(r)},t)}},{key:"refreshToken",value:function(e){return nu(function(){var r,t,n,o;return nf(this,function(a){switch(a.label){case 0:return[4,tq.refreshToken({refreshToken:e.refresh_token,clientId:this.clientId})];case 1:if(O(r=a.sent()))return t$("Error refreshing token",r.error),[2];return n={access_token:(t=r.value).access_token,refresh_token:t.refresh_token,token_type:t.token_type,expires_at:Date.now()+1e3*t.expires_in},[4,nc().save(n)];case 2:if(O(o=a.sent()))return t0(o.error),[2];return this.scheduleRefresh(n),[2]}})}).call(this)}},{key:"logout",value:function(){return nu(function(){return nf(this,function(e){switch(e.label){case 0:return null!==this.refreshTimeout&&(clearTimeout(this.refreshTimeout),this.refreshTimeout=null),[4,nc().delete()];case 1:return e.sent(),[2]}})}).call(this)}}],function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,e),r}());function nd(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function nh(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var nb=b.object({include:b.array(b.string())}).passthrough();function ny(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var nv=".gitignore",nm="node_modules\ngraphql.d.ts\n".concat(e4,"\n.DS_Store\n");function nw(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function ng(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){nw(a,n,o,i,c,"next",e)}function c(e){nw(a,n,o,i,c,"throw",e)}i(void 0)})}}function nE(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function n_(e){return ng(function(){var r,t,n,o;return nE(this,function(a){switch(a.label){case 0:return[4,rr("Loading workspaces...","Workspaces loaded",function(){return ng(function(){return nE(this,function(e){switch(e.label){case 0:return[4,tq.fetchWorkspaces()];case 1:return[2,e.sent()]}})})()})];case 1:if(O(r=a.sent()))return[2,r];if(n=(t=r.value).find(function(r){return r.slug===e}))return process.stdout.write("Using workspace: ".concat(n.name)),[2,m(n)];if(e)return[2,w({code:"NO_WORKSPACE_FOUND",workspace_slug:e})];if(0===t.length)return[2,w({code:"NO_WORKSPACES_FOUND"})];if(1===t.length)return process.stdout.write("Using workspace: ".concat(t[0].name)),[2,m(t[0])];return[4,ei({message:"Choose a workspace",choices:t.map(function(e){return{name:e.name,value:e}})})];case 2:return o=a.sent(),process.stdout.write("Using workspace: ".concat(o.name)),[2,m(o)]}})})()}function nO(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nk(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){nO(a,n,o,i,c,"next",e)}function c(e){nO(a,n,o,i,c,"throw",e)}i(void 0)})}}function nS(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function nI(e){return nk(function(){return nS(this,function(r){switch(r.label){case 0:return[4,rr("Loading app information...",function(e){return"App found: ".concat(e.title)},function(){return nk(function(){return nS(this,function(r){switch(r.label){case 0:return[4,tq.fetchAppInfo(e)];case 1:return[2,r.sent()]}})})()})];case 1:return[2,r.sent()]}})})()}function nT(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var nx=b.object({name:b.string({required_error:"No name field found in package.json",invalid_type_error:'"name" must be a string in package.json'})});function nA(){var e;return(e=function(){var e,r,t;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){try{if(e=l(process.cwd(),"package.json"),r=JSON.parse(s(e,"utf8")),!(t=nx.safeParse(r)).success)return[2,w({code:"MALFORMED_PACKAGE_JSON",error:t.error})];return[2,m(t.data.name)]}catch(e){var o;if(null!=(o=SyntaxError)&&"undefined"!=typeof Symbol&&o[Symbol.hasInstance]?!!o[Symbol.hasInstance](e):e instanceof o)return[2,w({code:"INVALID_JSON",error:e})];return[2,w({code:"FILE_SYSTEM_ERROR",error:e})]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){nT(a,n,o,i,c,"next",e)}function c(e){nT(a,n,o,i,c,"throw",e)}i(void 0)})})()}var nR=r(e(import.meta.url)),nj=b.object({name:b.literal("attio"),version:b.string({required_error:"No CLI version found",invalid_type_error:"CLI version must be a string in package.json"})});function nP(){if(void 0===em){var e,r,t=ec("package.json",{cwd:nR});if(void 0===t)return w({code:"UNABLE_TO_FIND_PACKAGE_JSON",path:nR});try{e=s(t,"utf8")}catch(e){return w({code:"UNABLE_TO_READ_PACKAGE_JSON",error:e})}try{r=JSON.parse(e)}catch(e){return w({code:"UNABLE_TO_PARSE_PACKAGE_JSON",error:e})}var n=nj.safeParse(r);if(!n.success)return w({code:"INVALID_PACKAGE_JSON",error:n.error});em=n.data}var o=em.version;return o?m(o):w({code:"NO_CLI_VERSION_FOUND"})}function nN(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nD(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){nN(a,n,o,i,c,"next",e)}function c(e){nN(a,n,o,i,c,"throw",e)}i(void 0)})}}function nC(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var nF=".env";function nL(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nU(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nM(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){nU(a,n,o,i,c,"next",e)}function c(e){nU(a,n,o,i,c,"throw",e)}i(void 0)})}}function nG(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function nB(e,r){function t(t){var n=t.toString().trim().toLowerCase();"\x03"!==n&&n===e.toLowerCase()&&r()}return process.stdin.isTTY&&(process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding("utf8"),process.stdin.on("data",t)),function(){process.stdin.isTTY&&(process.stdin.removeListener("data",t),process.stdin.setRawMode(!1),process.stdin.pause())}}var nV=r(e(import.meta.url));function nW(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nJ(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nY(){process.stdout.write('\uD83D\uDEA8 IMPORTANT: You will need to install your app in your workspace. Press "i" to open the app settings page, and then click "Install".\n\n')}function nK(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nH(e,r){var t;return(t=function(){return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,fetch(r,{method:"PUT",body:e,headers:{"Content-Type":"text/javascript","Content-Length":String(Buffer.from(e).length)}})];case 1:return t.sent(),[2,m(void 0)];case 2:return t.sent(),[2,w({code:"BUNDLE_UPLOAD_ERROR",upload_url:r})];case 3:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(n,o){var a=t.apply(e,r);function i(e){nK(a,n,o,i,c,"next",e)}function c(e){nK(a,n,o,i,c,"throw",e)}i(void 0)})})()}function nq(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function n$(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nX(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){n$(a,n,o,i,c,"next",e)}function c(e){n$(a,n,o,i,c,"throw",e)}i(void 0)})}}function nz(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function nQ(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nZ(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function n0(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function n1(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){n0(a,n,o,i,c,"next",e)}function c(e){n0(a,n,o,i,c,"throw",e)}i(void 0)})}}function n2(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var n4=function(e){try{z.notify({title:"TypeScript Error".concat(1===e.length?"":"s"),message:"There ".concat(1===e.length?"was one error":"were ".concat(e.length," errors")," in your TypeScript code")})}catch(e){}},n3=function(e){var r,t,n=((null==(r=e.errors)?void 0:r.length)||0)+((null==(t=e.warnings)?void 0:t.length)||0);try{z.notify({title:"JavaScript ".concat(1===n?"Error":"Errors"),message:"There ".concat(1===n?"was one error":"were ".concat(n," errors")," in your JavaScript code")})}catch(e){}},n6=b.object({workspace:b.string().optional(),app:b.string().optional()}),n5=new d("dev").description("Develop your Attio app").addOption(new h("-w, --workspace <slug>","The slug of the workspace to use")).addOption(new h("-a, --app <slug>","The app slug to use (overrides package.json)")).action(function(e){return n1(function(){var r,n,o,a,i,s,l,f,p,d,h,b,y,_,k,S,T,x,A,P,N,D,C,F;return n2(this,function(L){var U,M,G,B,W,J,K,H,q,$,X,Q,Z,en,ei,ec,el;switch(L.label){case 0:return n=(r=n6.parse(e)).workspace,o=r.app,a=[],i=!1,[4,e0(!0)];case 1:if(O(s=L.sent()))switch(s.error.code){case"APP_ENTRY_POINT_NOT_FOUND":e1("Could not find app.ts");case"FAILED_TO_GENERATE_ENTRY_POINT":e1("Failed to generate app.ts")}return[4,(U=function(){var e,r,t;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:e=u.resolve("."),r=u.join(e,nv),n.label=1;case 1:return n.trys.push([1,7,,13]),[4,I.readFile(r,"utf-8")];case 2:if(n.sent().split(/\r?\n/).includes(e4))return[3,6];n.label=3;case 3:return n.trys.push([3,5,,6]),[4,I.appendFile(r,"\n"+e4+"\n")];case 4:return n.sent(),[3,6];case 5:return n.sent(),[2,w({code:"FAILED_TO_ADD_HIDDEN_FILES_TO_GITIGNORE"})];case 6:return[2,m(void 0)];case 7:if(!((void 0===(t=n.sent())?"undefined":t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t)=="object"&&null!==t&&"code"in t&&"ENOENT"===t.code))return[3,12];n.label=8;case 8:return n.trys.push([8,10,,11]),[4,I.writeFile(nv,nm)];case 9:return n.sent(),[3,11];case 10:return n.sent(),[2,w({code:"FAILED_TO_CREATE_GITIGNORE"})];case 11:return[2,m(void 0)];case 12:return[2,w({code:"FAILED_TO_READ_GITIGNORE"})];case 13:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(t,n){var o=U.apply(e,r);function a(e){ny(o,t,n,a,i,"next",e)}function i(e){ny(o,t,n,a,i,"throw",e)}a(void 0)})})()];case 2:return L.sent(),[4,(M=function(){var e,r,t,n,o,a;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:return e=u.resolve("./tsconfig.json"),[4,g(I.readFile(e,"utf-8"))];case 1:var c,s,l;if(O(r=i.sent())){if((void 0===(t=r.error)?"undefined":t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t)=="object"&&null!==t&&"code"in t&&"ENOENT"===t.code)return[2,w({code:"TS_CONFIG_NOT_FOUND"})];return[2,w({code:"FAILED_TO_READ_TSCONFIG"})]}if(O(n=E(function(){return nb.parse(JSON.parse(r.value))})))return[2,w({code:"FAILED_TO_PARSE_TSCONFIG"})];if(o="".concat(e4,"/**/*"),n.value.include.includes(o))return[2,m(!1)];return s=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(r){var n;n=t[r],r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n})}return e}({},n.value),l=l={include:((function(e){if(Array.isArray(e))return nd(e)})(c=n.value.include)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(c)||function(e,r){if(e){if("string"==typeof e)return nd(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return nd(e,r)}}(c)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([o])},Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(l)):(function(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(l)).forEach(function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(l,e))}),a=s,[4,g(I.writeFile(e,JSON.stringify(a,null,2)))];case 2:if(O(i.sent()))return[2,w({code:"FAILED_TO_WRITE_TSCONFIG"})];return[2,m(!0)]}})},function(){var e=this,r=arguments;return new Promise(function(t,n){var o=M.apply(e,r);function a(e){nh(o,t,n,a,i,"next",e)}function i(e){nh(o,t,n,a,i,"throw",e)}a(void 0)})})()];case 3:if(O(l=L.sent()))switch(l.error.code){case"TS_CONFIG_NOT_FOUND":case"FAILED_TO_READ_TSCONFIG":case"FAILED_TO_PARSE_TSCONFIG":case"FAILED_TO_WRITE_TSCONFIG":process.stderr.write(R.yellow('Failed to update tsconfig. Make sure the "include" field contains the '.concat(e4," directory \n")));break;default:throw Error(l.error)}return[4,e5()];case 4:return O(L.sent())&&e1("Failed to generate settings types"),[4,np.ensureAuthed()];case 5:L.sent(),f=function(){return n1(function(){var e,r,t,n,o,c,s,u,l;return n2(this,function(f){switch(f.label){case 0:if(i)return[2];i=!0,f.label=1;case 1:f.trys.push([1,12,,13]),e=!0,r=!1,t=void 0,f.label=2;case 2:f.trys.push([2,9,10,11]),n=a.reverse()[Symbol.iterator](),f.label=3;case 3:if(e=(o=n.next()).done)return[3,8];c=o.value,f.label=4;case 4:return f.trys.push([4,6,,7]),[4,Promise.race([c(),new Promise(function(e,r){return setTimeout(function(){return r(Error("Cleanup timeout"))},2e3)})])];case 5:return f.sent(),[3,7];case 6:return s=f.sent(),process.stderr.write(R.yellow("Warning during cleanup: ".concat(s,"\n"))),[3,7];case 7:return e=!0,[3,3];case 8:return[3,11];case 9:return u=f.sent(),r=!0,t=u,[3,11];case 10:try{e||null==n.return||n.return()}finally{if(r)throw t}return[7];case 11:return[3,13];case 12:return l=f.sent(),process.stderr.write(R.red("Error during cleanup: ".concat(l,"\n"))),[3,13];case 13:return[2]}})})()},L.label=6;case 6:return L.trys.push([6,9,,11]),[4,function(e){var r;return(r=function(e){var r,t,n,o,a,i,s,u,l,f,p,d,h,b;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(y){switch(y.label){case 0:if(r=e.workspaceSlug,!(t=e.appSlug))return[3,1];return o=m(t),[3,3];case 1:return[4,nA()];case 2:o=y.sent(),y.label=3;case 3:return O(n=o)&&(tz(n.error),process.exit(1)),[4,nI(a=n.value)];case 4:return O(i=y.sent())&&(tX(i.error),process.exit(1)),s=i.value,[4,n_(r)];case 5:return O(u=y.sent())&&(tZ(u.error),process.exit(1)),l=u.value,[4,nD(function(){var e;return nC(this,function(r){switch(r.label){case 0:return[4,nD(function(){return nC(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,c.access(nF)];case 1:return e.sent(),[2,!0];case 2:return e.sent(),[2,!1];case 3:return[2]}})})()];case 1:if(!r.sent())return[2,{}];return[4,c.readFile(nF,{encoding:"utf8"})];case 2:e=r.sent();try{return[2,es.parse(e)]}catch(e){throw Error("Failed to parse ".concat(nF))}}})})()];case 6:return f=y.sent(),O(p=nP())&&(tQ(p),process.exit(1)),d=p.value,[4,tq.createDevVersion({appId:s.app_id,cliVersion:d,targetWorkspaceId:l.workspace_id,environmentVariables:f})];case 7:return O(h=y.sent())&&(t$("Error creating dev version",h.error),process.exit(1)),b=h.value,[2,{appId:s.app_id,appSlug:a,devVersionId:b.app_dev_version_id,workspace:l}]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(e){nL(a,n,o,i,c,"next",e)}function c(e){nL(a,n,o,i,c,"throw",e)}i(void 0)})}).apply(this,arguments)}({workspaceSlug:n,appSlug:o})];case 7:return d=(p=L.sent()).appId,h=p.appSlug,b=p.workspace,y=p.devVersionId,B=null,W=!1,(J=function(){var e,r,n,o,a,i,c;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(s){switch(s.label){case 0:if(W)return[2];s.label=1;case 1:return s.trys.push([1,3,,4]),e=nV,r=u.resolve(e,"..","..","schema.graphql"),n=t.readFileSync(r,"utf8"),[4,t6(8700)];case 2:return G=s.sent(),o=Y(n),a=new er,i=function(){return{}},a.use("/graphql",eu({schema:o,rootResolver:i,graphiql:!0})),B=ee({fetch:a.fetch,port:G}),process.stdout.write('\n\n Press "o" to open GraphQL Explorer.\n\n'),[3,4];case 3:throw c=s.sent(),process.stderr.write("Failed to start GraphQL server: ".concat(c,"\n")),c;case 4:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(t,n){var o=J.apply(e,r);function a(e){nW(o,t,n,a,i,"next",e)}function i(e){nW(o,t,n,a,i,"throw",e)}a(void 0)})})().catch(function(e){process.stderr.write("GraphQL server failed to start: ".concat(e,"\n"))}),K=nB("o",function(){G&&et("http://localhost:".concat(G,"/graphql"))}),_=function(){if(W=!0,K(),B)try{B.close()}catch(e){process.stderr.write("Error closing GraphQL server: ".concat(e,"\n"))}},a.push(_),q=(H={appId:d,appSlug:h,workspace:b}).appId,$=H.appSlug,X=H.workspace,Q=nB("i",function(){et("".concat(tg,"/").concat(X.slug,"/settings/apps/").concat($))}),(Z=function(){var e,r,t;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:return[4,tq.fetchInstallation({appId:q,workspaceId:X.workspace_id})];case 1:if(O(e=n.sent()))return[2];if(r=e.value)return[3,6];nY(),n.label=2;case 2:if(r)return[3,5];return[4,new Promise(function(e){return setTimeout(e,6e4)})];case 3:return n.sent(),[4,tq.fetchInstallation({appId:q,workspaceId:X.workspace_id})];case 4:if(O(t=n.sent()))return[2];return(r=t.value)||nY(),[3,2];case 5:Q(),n.label=6;case 6:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(t,n){var o=Z.apply(e,r);function a(e){nJ(o,t,n,a,i,"next",e)}function i(e){nJ(o,t,n,a,i,"throw",e)}a(void 0)})})(),k=Q,a.push(k),S=!1,en=function(e,r){var t=!1,n=V.watch(["src/**/*.ts","src/**/*.tsx"],{ignored:["**/node_modules/**","**/dist/**","**/*.graphql.d.ts","**/*.gql.d.ts"],cwd:".",persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:100}});function o(){var n;return(n=function(){var n,o,a,i;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(c){switch(c.label){case 0:if(t)return[2];c.label=1;case 1:return c.trys.push([1,4,,5]),[4,rs(u.resolve("tsconfig.json"))];case 2:if("Not a TypeScript project"===(n=c.sent()))return null==e||e(),[2];return[4,ru(n)];case 3:return(o=c.sent()).length?null==r||r(o):null==e||e(),[3,5];case 4:var s;if((void 0===(a=c.sent())?"undefined":a&&"undefined"!=typeof Symbol&&a.constructor===Symbol?"symbol":typeof a)=="object"&&null!==a&&"code"in a&&("ENOENT"===a.code||"EACCES"===a.code||"EPERM"===a.code))throw a;return(null!=(s=Error)&&"undefined"!=typeof Symbol&&s[Symbol.hasInstance]?!!s[Symbol.hasInstance](a):a instanceof s)&&(i=rc.parse({text:a.message}),null==r||r([i])),[3,5];case 5:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(t,o){var a=n.apply(e,r);function i(e){nQ(a,t,o,i,c,"next",e)}function c(e){nQ(a,t,o,i,c,"throw",e)}i(void 0)})})()}var a=!1;return n.on("ready",function(){a=!0,n.on("all",function(e,r){("add"===e||"change"===e||"unlink"===e)&&o()})}),n.on("error",function(e){process.stderr.write("TypeScript watcher error: ".concat(e,"\n"))}),[function(){if(t=!0,a)try{n.close()}catch(e){process.stderr.write("Error closing TypeScript watcher: ".concat(e,"\n"))}},o]}(function(){S&&(process.stdout.write("".concat(R.green("✓")," TypeScript errors fixed\n")),S=!1)},function(e){S=!0,e.forEach(rl),n4(e)}),x=(T=function(e){if(Array.isArray(e))return e}(en)||function(e,r){var t,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(t=o.next()).done)&&(a.push(t.value),a.length!==r);i=!0);}catch(e){c=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw n}}return a}}(en,2)||function(e,r){if(e){if("string"==typeof e)return nZ(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return nZ(e,r)}}(en,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],A=T[1],a.push(x),P=!1,ei=function(){P&&(process.stdout.write("".concat(R.green("✓")," GraphQL errors fixed\n")),P=!1),A()},ec=function(e){P=!0,process.stderr.write(e)},(el=V.watch(["**/*.graphql","**/*.gql"],{ignored:["**/node_modules/**","**/dist/**"],cwd:"."})).on("ready",function(){return tf(function(){var e;return td(this,function(r){switch(r.label){case 0:return[4,th()];case 1:return O(e=r.sent())?"GRAPHQL_ERROR"===e.error.code?null==ec||ec(e.error.error.toString()):e1(e.error.error.toString()):null==ei||ei(),el.on("all",function(e,r){return tf(function(){var r;return td(this,function(t){switch(t.label){case 0:if("add"!==e&&"change"!==e&&"unlink"!==e)return[3,2];return[4,th()];case 1:O(r=t.sent())?"GRAPHQL_ERROR"===r.error.code?null==ec||ec(r.error.error.toString()):e1(r.error.error.toString()):null==ei||ei(),t.label=2;case 2:return[2]}})})()}),[2]}})})()}),N=function(){el.close()},a.push(N),D=!1,C=function(e,r){var t,n=V.watch(["./src/**/*.{js,jsx,ts,tsx}"],{ignored:["**/node_modules/**","**/dist/**","**/*.graphql.d.ts","**/*.gql.d.ts"],cwd:process.cwd()}),o=!1,a=!1,i=!1;function c(){return nM(function(){var r,n,s;return nG(this,function(u){switch(u.label){case 0:if(o||i)return a=!0,[2,m(void 0)];o=!0,u.label=1;case 1:if(u.trys.push([1,,8,9]),t)return[3,3];return[4,rQ("in-memory")];case 2:if(O(r=u.sent()))return[2,r];t=r.value,u.label=3;case 3:return[4,t.rebuild()];case 4:if(O(n=u.sent()))return[2,n];return s=n.value,[4,null==e?void 0:e([s.client.outputFiles[0].text,s.server.outputFiles[0].text])];case 5:if(u.sent(),o=!1,!(a&&!i))return[3,7];return a=!1,[4,c()];case 6:return[2,u.sent()];case 7:return[2,m(void 0)];case 8:return o=!1,[7];case 9:return[2]}})})()}return n.on("ready",function(){return nM(function(){var e;return nG(this,function(t){switch(t.label){case 0:return[4,c()];case 1:return O(e=t.sent())&&(null==r||r(e.error)),n.on("all",function(e){return nM(function(){var t;return nG(this,function(n){switch(n.label){case 0:if("add"!==e&&"change"!==e&&"unlink"!==e)return[3,2];return[4,c()];case 1:O(t=n.sent())&&(null==r||r(t.error)),n.label=2;case 2:return[2]}})})()}),[2]}})})()}),function(){return nM(function(){var e;return nG(this,function(r){switch(r.label){case 0:if(i=!0,!o)return[3,2];return[4,new Promise(function(e){var r=setInterval(function(){o||(clearInterval(r),e(void 0))},10)})];case 1:r.sent(),r.label=2;case 2:return[4,n.close()];case 3:if(r.sent(),!t)return[3,5];return[4,t.dispose(1e3)];case 4:O(e=r.sent())&&process.stderr.write("Error disposing build context: ".concat(e.error,"\n")),t=void 0,r.label=5;case 5:return[2]}})})()}}(function(e){return n1(function(){var r;return n2(this,function(t){switch(t.label){case 0:return D&&(process.stdout.write("".concat(R.green("✓")," Bundling errors fixed\n")),D=!1),[4,function(e){return nX(function(e){var r,t,n;return nz(this,function(o){switch(o.label){case 0:return r=e.contents,t=e.devVersionId,n=e.appId,[4,rr("Uploading...",function(){return"Upload complete at ".concat(new Date().toLocaleTimeString())},function(){return nX(function(){var e,o,a,i,c,s,u,l,f,p;return nz(this,function(d){switch(d.label){case 0:return[4,tq.startUpload({appId:n,devVersionId:t})];case 1:if(O(e=d.sent()))return[2,e];return a=(o=e.value).client_bundle_upload_url,i=o.server_bundle_upload_url,c=o.app_dev_version_bundle_id,u=(s=function(e){if(Array.isArray(e))return e}(r)||function(e,r){var t,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(t=o.next()).done)&&(a.push(t.value),a.length!==r);i=!0);}catch(e){c=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw n}}return a}}(r,2)||function(e,r){if(e){if("string"==typeof e)return nq(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return nq(e,r)}}(r,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],l=s[1],[4,v([nH(u,a),nH(l,i)])];case 2:if(O(f=d.sent()))return[2,f];return[4,tq.completeBundleUpload({appId:n,devVersionId:t,bundleId:c})];case 3:if(O(p=d.sent()))return[2,p];try{z.notify({title:"Upload Complete",message:"New bundle uploaded to Attio"})}catch(e){}return[2,m(void 0)]}})})()})];case 1:return[2,o.sent()]}})}).apply(this,arguments)}({contents:e,devVersionId:y,appId:d})];case 1:return O(r=t.sent())&&function(e){switch(e.code){case"BUNDLE_UPLOAD_ERROR":process.stderr.write(R.red("Error uploading bundle: ".concat(e.upload_url,"\n")));break;case"START_UPLOAD_ERROR":t$("Error starting upload",e);break;case"COMPLETE_BUNDLE_UPLOAD_ERROR":t$("Error completing bundle upload",e);break;default:return}}(r.error),[2]}})})()},function(e){return n1(function(){var r,t;return n2(this,function(n){return D=!0,"BUILD_JAVASCRIPT_ERROR"===e.code?(n3(e),r=e.errors,t=e.warnings,null==r||r.forEach(function(e){return rf(e,"error")}),null==t||t.forEach(function(e){return rf(e,"warning")})):rZ(e),[2]})})()}),a.push(C),eo.block(),ea.hide(),j.cursorTo(process.stdout,0),process.stdout.write("\n\uD83D\uDC40 Watching for changes..."),j.clearLine(process.stdout,1),process.on("SIGINT",function(){return n1(function(){return n2(this,function(e){switch(e.label){case 0:return[4,f()];case 1:return e.sent(),process.exit(0),[2]}})})()}),process.on("SIGTERM",function(){return n1(function(){return n2(this,function(e){switch(e.label){case 0:return[4,f()];case 1:return e.sent(),process.exit(0),[2]}})})()}),process.on("uncaughtException",function(e){return n1(function(){return n2(this,function(r){switch(r.label){case 0:return process.stderr.write(R.red("Uncaught exception: ".concat(e,"\n"))),[4,f()];case 1:return r.sent(),process.exit(1),[2]}})})()}),process.on("unhandledRejection",function(e){return n1(function(){return n2(this,function(r){switch(r.label){case 0:return process.stderr.write(R.red("Unhandled rejection: ".concat(e,"\n"))),[4,f()];case 1:return r.sent(),process.exit(1),[2]}})})()}),[4,new Promise(function(){})];case 8:return L.sent(),[3,11];case 9:return F=L.sent(),process.stderr.write(R.red("✖ ".concat(F,"\n"))),[4,f()];case 10:return L.sent(),process.exit(1),[3,11];case 11:return[2]}})})()}),n7=function(e){try{return n(f(e),o.W_OK),!0}catch(e){return!1}};function n8(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function n9(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){n8(a,n,o,i,c,"next",e)}function c(e){n8(a,n,o,i,c,"throw",e)}i(void 0)})}}function oe(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function or(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var ot=function(e){var r;return(r=function(){var r,t;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:t=l(r=process.cwd(),e),n.label=1;case 1:return n.trys.push([1,5,,6]),[4,c.access(t).then(function(){return!0}).catch(function(){return!1})];case 2:if(n.sent())return[2,w({code:"DIRECTORY_ALREADY_EXISTS",path:t})];return[4,c.access(r,o.W_OK)];case 3:return n.sent(),[4,c.mkdir(t)];case 4:return n.sent(),[2,m(t)];case 5:return n.sent(),[2,w({code:"WRITE_ACCESS_DENIED",path:e})];case 6:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(e){or(a,n,o,i,c,"next",e)}function c(e){or(a,n,o,i,c,"throw",e)}i(void 0)})})()},on=r(e(import.meta.url));function oo(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function oa(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){oo(a,n,o,i,c,"next",e)}function c(e){oo(a,n,o,i,c,"throw",e)}i(void 0)})}}function oi(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function oc(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var os=b.string(),ou=new d("init").description("Initialize a new Attio app").addArgument(new p("<app-slug>","The app slug, chosen in the developer dashboard")).action(function(e){var r;return(r=function(){var r,t,n,o,a;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),process.stdout.write("\n".concat(" *@@@@#= ++:\n #@@@@# :# :+# =+@ @@+\n #@@@@# + +++ :++ -*@@::::@@@:: --. +++:\n #@@@@+ :: :%@@@@@@@@ @@@@@@@@@@@@@ @@+ :#@@@@@@=\n #@@@@: *:++++ :@@+ +@@@ +@@ @@@ @@+:@@# +@@+\n #@@@@: *:#@@# + *@# +@@ +@@ @@@ @@++@@ +@@\n@@@@@- + #@@# + +@@: :@@@ +@@ @@@ @@+=@@: #@#\n:@@@@%: + #@@@@: :: #@@@+@@@@@ :@@@@+ +@@@@ @@+ +@@@+#@@#\n :@@@@@+ #@@@@+: :++++++++ :+++: ++++ ++: +++++:","\n\n")),r=os.parse(e),[4,np.ensureAuthed()];case 1:return s.sent(),[4,nI(r)];case 2:return O(t=s.sent())&&(tX(t.error),process.exit(1)),n=t.value,[4,function(e){return oa(function(e){var r,t;return oi(this,function(n){switch(n.label){case 0:return r=e.appSlug,t=e.appInfo,[4,rr("Creating project...","Project created",function(){return oa(function(){var e,n,o,a,s;return oi(this,function(l){switch(l.label){case 0:if(e=process.cwd(),i(n=u.join(e,r)))return[2,w({code:"DIRECTORY_ALREADY_EXISTS",path:n})];if(!n7(e))return[2,w({code:"WRITE_ACCESS_DENIED",path:e})];return[4,ot(r)];case 1:if(O(o=l.sent()))return[2,o];return a=o.value,[4,function e(r,t,n){return n9(function(){var o,a;return oe(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,c.mkdir(t,{recursive:!0})];case 1:return i.sent(),[3,3];case 2:return i.sent(),[2,w({code:"FAILED_TO_CREATE_DIRECTORY",path:t})];case 3:return i.trys.push([3,5,,6]),[4,c.readdir(r,{withFileTypes:!0})];case 4:return o=i.sent(),[3,6];case 5:return i.sent(),[2,w({code:"FAILED_TO_LIST_FILES",path:r})];case 6:return[4,v(o.map(function(o){return n9(function(){var a,i,s;return oe(this,function(l){switch(l.label){case 0:if(a=u.join(r,o.name),i=u.join(t,o.name),!o.isDirectory())return[3,2];return[4,e(a,i,n)];case 1:return[2,l.sent()];case 2:if(!o.isFile())return[3,14];if(!(o.name.startsWith(".")||/\.(jpg|jpeg|png|gif|svg|webp|ico)$/i.test(o.name)))return[3,7];l.label=3;case 3:return l.trys.push([3,5,,6]),[4,c.copyFile(a,i)];case 4:return l.sent(),[3,6];case 5:return l.sent(),[2,w({code:"FAILED_TO_COPY_FILE",src:a,dest:i})];case 6:return[3,14];case 7:return l.trys.push([7,9,,10]),[4,c.readFile(a,"utf8")];case 8:return s=l.sent(),[3,10];case 9:return l.sent(),[2,w({code:"FAILED_TO_READ_FILE",path:a})];case 10:s=n(s),l.label=11;case 11:return l.trys.push([11,13,,14]),[4,c.writeFile(i,s,"utf8")];case 12:return l.sent(),[3,14];case 13:return l.sent(),[2,w({code:"FAILED_TO_WRITE_FILE",path:i})];case 14:return[2,m(void 0)]}})})()}))];case 7:if(O(a=i.sent()))return[2,a];return[2,m(void 0)]}})})()}(u.resolve(on,"../template"),a,function(e){return e.replaceAll("title-to-be-replaced",t.title).replaceAll("id-to-be-replaced",t.app_id).replaceAll("slug-to-be-replaced",r)})];case 2:if(O(s=l.sent()))return[2,s];return[2,m(void 0)]}})})()})];case 1:return[2,n.sent()]}})}).apply(this,arguments)}({appSlug:r,appInfo:n})];case 3:return O(o=s.sent())&&(!function(e){switch(e.code){case"DIRECTORY_ALREADY_EXISTS":process.stderr.write(R.red("✖ Directory ".concat(e.path," already exists.\n")));break;case"WRITE_ACCESS_DENIED":process.stderr.write(R.red("✖ Write access denied to ".concat(e.path,"\n")));break;case"FAILED_TO_CREATE_DIRECTORY":process.stderr.write(R.red("✖ Failed to create directory ".concat(e.path,"\n")));break;case"FAILED_TO_COPY_FILE":process.stderr.write(R.red("✖ Failed to copy file ".concat(e.src," to ").concat(e.dest,"\n")));break;case"FAILED_TO_LIST_FILES":process.stderr.write(R.red("✖ Failed to list files in ".concat(e.path,"\n")));break;case"FAILED_TO_READ_FILE":process.stderr.write(R.red("✖ Failed to read file ".concat(e.path,"\n")));break;case"FAILED_TO_WRITE_FILE":process.stderr.write(R.red("✖ Failed to write file ".concat(e.path,"\n")));break;default:return}}(o.error),process.exit(1)),process.stdout.write("".concat(R.green("SUCCESS!! \uD83C\uDF89 Your app directory has been created."),"\n\nTo get started, run:\n\n").concat(el("cd ".concat(r,"\nnpm install\nnpm run dev"),{padding:1,margin:1,borderStyle:"round"}),"\n\n(").concat(R.yellow("yarn"),", ").concat(R.yellow("pnpm"),", and ").concat(R.yellow("bun")," also work!)\n")),process.exit(0),[3,5];case 4:return a=s.sent(),process.stderr.write("".concat(R.red("✖ ".concat(a)),"\n")),process.exit(1),[3,5];case 5:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(e){oc(a,n,o,i,c,"next",e)}function c(e){oc(a,n,o,i,c,"throw",e)}i(void 0)})})()});function ol(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var of=new d("login").description("Authenticate with Attio").action(function(){var e;return(e=function(){var e;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){switch(r.label){case 0:return[4,np.authenticate()];case 1:return O(e=r.sent())&&(!function(e){switch(e.code){case"GET_TOKEN_ERROR":t$("Error getting token",e);break;case"REFRESH_TOKEN_ERROR":t$("Error refreshing token",e);break;case"NO_AUTHORIZATION_CODE":process.stderr.write(R.red("No authorization code received"));break;case"OAUTH_STATE_MISMATCH":process.stderr.write(R.red("OAuth state mismatch, possible CSRF attack"));break;case"SAVE_KEYCHAIN_ERROR":case"LOAD_KEYCHAIN_ERROR":case"DELETE_KEYCHAIN_ERROR":t0(e);break;default:return}}(e.error),process.exit(1)),process.stdout.write("\uD83D\uDD13 Successfully authenticated.\n"),process.exit(0),[2]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){ol(a,n,o,i,c,"next",e)}function c(e){ol(a,n,o,i,c,"throw",e)}i(void 0)})})()});function op(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var od=new d("logout").description("Log out from Attio").action(function(){var e;return(e=function(){var e;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){switch(r.label){case 0:return[4,nc().delete()];case 1:return O(e=r.sent())&&(t0(e.error),process.exit(1)),process.stdout.write("\uD83D\uDD12 Successfully logged out.\n"),process.exit(0),[2]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){op(a,n,o,i,c,"next",e)}function c(e){op(a,n,o,i,c,"throw",e)}i(void 0)})})()});function oh(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function ob(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function oy(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){ob(a,n,o,i,c,"next",e)}function c(e){ob(a,n,o,i,c,"throw",e)}i(void 0)})}}function ov(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function om(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(t=o.next()).done)&&(a.push(t.value),!r||a.length!==r);i=!0);}catch(e){c=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw n}}return a}}(e,r)||function(e,r){if(e){if("string"==typeof e)return oh(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return oh(e,r)}}(e,r)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ow(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function og(e){return w({code:"FAILED_TO_CONNECT_TO_REALTIME_SERVER",error:e})}var oE=function(){"use strict";var e;function r(){if(!(this instanceof r))throw TypeError("Cannot call a class as a function");ov(this,"_ablyRealtime",void 0),ov(this,"_channels",new Map),ov(this,"_suspendListeners",new Set),this._ablyRealtime=this._createAblyRealtime()}return e=[{key:"subscribe",value:function(e,r,t,n){return oy(function(){var o,a,i,c,s;return ow(this,function(u){switch(u.label){case 0:if(o=this,a=this._channels.get(e))return[3,2];return a={listeners:new Map},[4,this._authorizeChannel(e)];case 1:if(O(i=u.sent()))return[2,og(i.error.error)];this._channels.set(e,a),u.label=2;case 2:return(c=a.listeners.get(r))||(c=new Set,a.listeners.set(r,c)),[4,this._subscribe(e,r,function(e){var r=t.safeParse(e);r.success&&n(r.data)})];case 3:if(O(s=u.sent()))return[2,og(s.error.error)];return c.add(n),[2,m({unsubscribe:function(){return oy(function(){return ow(this,function(t){switch(t.label){case 0:return[4,this._unsubscribe(e,r,n)];case 1:return t.sent(),[2]}})}).call(o)}})]}})}).call(this)}},{key:"reconnect",value:function(){return oy(function(){var e,r,t,n,o,a,i,c,s,u,l,f,p,d,h,b,y,v,w,g,E,_,k,S,I;return ow(this,function(T){switch(T.label){case 0:return[4,this._teardown()];case 1:T.sent(),this._ablyRealtime=this._createAblyRealtime(),e=!0,r=!1,t=void 0,T.label=2;case 2:T.trys.push([2,20,21,22]),n=this._channels[Symbol.iterator](),T.label=3;case 3:if(e=(o=n.next()).done)return[3,19];return i=(a=om(o.value,2))[0],c=a[1].listeners,[4,this._authorizeChannel(i)];case 4:if(O(s=T.sent()))return[2,og(s.error.error)];u=!0,l=!1,f=void 0,T.label=5;case 5:T.trys.push([5,16,17,18]),p=c[Symbol.iterator](),T.label=6;case 6:if(u=(d=p.next()).done)return[3,15];b=(h=om(d.value,2))[0],y=h[1],v=!0,w=!1,g=void 0,T.label=7;case 7:T.trys.push([7,12,13,14]),E=y[Symbol.iterator](),T.label=8;case 8:if(v=(_=E.next()).done)return[3,11];return k=_.value,[4,this._subscribe(i,b,k)];case 9:if(O(S=T.sent()))return[2,og(S.error.error)];T.label=10;case 10:return v=!0,[3,8];case 11:return[3,14];case 12:return I=T.sent(),w=!0,g=I,[3,14];case 13:try{v||null==E.return||E.return()}finally{if(w)throw g}return[7];case 14:return u=!0,[3,6];case 15:return[3,18];case 16:return I=T.sent(),l=!0,f=I,[3,18];case 17:try{u||null==p.return||p.return()}finally{if(l)throw f}return[7];case 18:return e=!0,[3,3];case 19:return[3,22];case 20:return I=T.sent(),r=!0,t=I,[3,22];case 21:try{e||null==n.return||n.return()}finally{if(r)throw t}return[7];case 22:return[2,m(!0)]}})}).call(this)}},{key:"onSuspended",value:function(e){var r=this;return this._suspendListeners.add(e),function(){r._suspendListeners.delete(e)}}},{key:"close",value:function(){return oy(function(){return ow(this,function(e){switch(e.label){case 0:return[4,this._teardown()];case 1:return e.sent(),[2]}})}).call(this)}},{key:"_createAblyRealtime",value:function(){var e=this,r=new ep.Realtime({logLevel:0,useTokenAuth:!0,autoConnect:!1,tls:!0,echoMessages:!1,authCallback:function(e,r){return oy(function(){var t;return ow(this,function(n){switch(n.label){case 0:return[4,tq.authenticateAbly(e)];case 1:if(O(t=n.sent()))return[2,r(t.error.message,null)];return[2,r(null,t.value)]}})})()}});return r.connection.on("suspended",function(){e._suspendListeners.forEach(function(e){return e()})}),r}},{key:"_authorizeChannel",value:function(e){return oy(function(){return ow(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this._ablyRealtime.auth.authorize({capability:ov({},"".concat(e),["subscribe"])})];case 1:return r.sent(),[2,m(!0)];case 2:return[2,w({code:"FAILED_TO_AUTHORIZE_CHANNEL",error:r.sent()})];case 3:return[2]}})}).call(this)}},{key:"_subscribe",value:function(e,r,t){return oy(function(){var n;return ow(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,(n=this._ablyRealtime.channels.get(e)).presence.enter()];case 1:return o.sent(),[4,n.subscribe(r,function(e){t(e.data.data)})];case 2:return o.sent(),[2,m(!0)];case 3:return[2,w({code:"FAILED_TO_SUBSCRIBE_TO_EVENTS",error:o.sent()})];case 4:return[2]}})}).call(this)}},{key:"_unsubscribe",value:function(e,r,t){return oy(function(){var n,o;return ow(this,function(a){switch(a.label){case 0:if(this._ablyRealtime.channels.get(e).unsubscribe(r,t),!(n=this._channels.get(e)))return[2,m(!0)];if((o=n.listeners.get(r))&&(o.delete(t),(null==o?void 0:o.size)===0&&n.listeners.delete(r)),0!==n.listeners.size)return[3,2];return[4,this._teardownChannel(e)];case 1:_(a.sent())&&this._channels.delete(e),a.label=2;case 2:return[2,m(!0)]}})}).call(this)}},{key:"_teardown",value:function(){return oy(function(){var e,r,t,n,o,a,i;return ow(this,function(c){switch(c.label){case 0:e=!0,r=!1,t=void 0,c.label=1;case 1:c.trys.push([1,6,7,8]),n=this._channels[Symbol.iterator](),c.label=2;case 2:if(e=(o=n.next()).done)return[3,5];return a=om(o.value,1)[0],[4,this._teardownChannel(a)];case 3:c.sent(),c.label=4;case 4:return e=!0,[3,2];case 5:return[3,8];case 6:return i=c.sent(),r=!0,t=i,[3,8];case 7:try{e||null==n.return||n.return()}finally{if(r)throw t}return[7];case 8:return this._ablyRealtime.close(),[2,m(!0)]}})}).call(this)}},{key:"_teardownChannel",value:function(e){return oy(function(){var r;return ow(this,function(t){switch(t.label){case 0:r=this._ablyRealtime.channels.get(e),t.label=1;case 1:return t.trys.push([1,4,,5]),[4,r.presence.leave()];case 2:return t.sent(),[4,r.detach()];case 3:return t.sent(),[2,m(!0)];case 4:return[2,w({code:"FAILED_TO_TEARDOWN_CHANNEL",error:t.sent()})];case 5:return[2]}})}).call(this)}}],function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,e),r}(),o_=b.union([b.literal("INFO"),b.literal("WARNING"),b.literal("ERROR")]),oO=b.object({message:b.string(),severity:o_,timestamp:b.string().datetime()});function ok(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var oS=function(){"use strict";var e;function r(e){var t=this;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");ok(this,"bufferDelayMs",void 0),ok(this,"buffer",void 0),ok(this,"listeners",void 0),ok(this,"flushInterval",void 0),this.bufferDelayMs=e,this.buffer=[],this.listeners=[],this.flushInterval=setInterval(function(){t.flush()},e/5)}return e=[{key:"close",value:function(){this.flushInterval&&clearInterval(this.flushInterval),this.flushInterval=null}},{key:"listen",value:function(e){this.assertNotClosed(),this.listeners.push(e)}},{key:"add",value:function(e){this.assertNotClosed();var r=Date.now(),t=this.buffer.findIndex(function(r){return e.timestamp>r.event.timestamp});t>=0?this.buffer.splice(t,0,{event:e,receivedAt:r}):this.buffer.push({event:e,receivedAt:r})}},{key:"flush",value:function(){var e=this,r=Date.now(),t=this.buffer.findIndex(function(t){return r-t.receivedAt>e.bufferDelayMs});if(-1!==t){var n=this.buffer.splice(t,this.buffer.length-t).reverse().map(function(e){return e.event}),o=!0,a=!1,i=void 0;try{for(var c,s=this.listeners[Symbol.iterator]();!(o=(c=s.next()).done);o=!0)(0,c.value)(n)}catch(e){a=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}}}},{key:"assertNotClosed",value:function(){if(null===this.flushInterval)throw Error("This buffer was closed")}}],function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,e),r}();function oI(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function oT(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){oI(a,n,o,i,c,"next",e)}function c(e){oI(a,n,o,i,c,"throw",e)}i(void 0)})}}function ox(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function oA(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function oR(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){oA(a,n,o,i,c,"next",e)}function c(e){oA(a,n,o,i,c,"throw",e)}i(void 0)})}}function oj(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var oP=b.object({workspace:b.string().optional(),app:b.string().optional()}),oN=new d("logs").description("Stream development server logs").addOption(new h("-w, --workspace <slug>","The slug of the workspace to get the logs from")).addOption(new h("-a, --app <slug>","The app slug to use (overrides package.json)")).action(function(e){return oR(function(){var r,t,n,o,a,i,c,s,u,l,f,p,d,h;return oj(this,function(b){switch(b.label){case 0:return t=(r=oP.parse(e)).workspace,n=r.app,[4,np.ensureAuthed()];case 1:if(b.sent(),!n)return[3,2];return a=m(n),[3,4];case 2:return[4,nA()];case 3:a=b.sent(),b.label=4;case 4:return O(o=a)&&(tz(o.error),process.exit(1)),[4,nI(o.value)];case 5:return O(i=b.sent())&&(tX(i.error),process.exit(1)),c=i.value,[4,n_(t)];case 6:return O(s=b.sent())&&(tZ(s.error),process.exit(1)),u=s.value,l=ef.createInterface({input:process.stdin,output:process.stdout}),f=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Press Enter to resume...";return oR(function(){return oj(this,function(r){switch(r.label){case 0:return[4,l.question(e)];case 1:return r.sent(),[2]}})})()},[4,rr("Connecting to log server...","Connected to log server",function(){return oR(function(){return oj(this,function(e){return[2,function(e,r,t){return oT(function(e,r,t){var n,o,a,i,c,s,u;return ox(this,function(l){switch(l.label){case 0:return n=e.workspaceId,o=e.appId,(a=new oS(200)).listen(function(e){return e.forEach(r)}),(i=new oE).onSuspended(function(){t({close:function(){return oT(function(){return ox(this,function(e){switch(e.label){case 0:return[4,i.close()];case 1:return e.sent(),[2]}})})()},reconnect:function(){return oT(function(){var e;return ox(this,function(r){switch(r.label){case 0:return[4,i.reconnect()];case 1:if(O(e=r.sent()))return[2,w({code:"FAILED_TO_CONNECT_TO_LOGS_SERVER",error:e.error.error})];return[2,m(!0)]}})})()}})}),c="ecosystem-app-logs:".concat(n,":").concat(o),[4,i.subscribe(c,"app-dev-log-emitted",oO,function(e){a.add(e)})];case 1:if(O(s=l.sent()))return[2,w({code:"FAILED_TO_CONNECT_TO_LOGS_SERVER",error:s.error.error})];return u=s.value,[2,m({unsubscribe:function(){return oT(function(){return ox(this,function(e){switch(e.label){case 0:return a.close(),[4,u.unsubscribe()];case 1:return e.sent(),[2]}})})()}})]}})}).apply(this,arguments)}({workspaceId:u.workspace_id,appId:c.app_id},function(e){var r,t=e.message,n=e.severity,o=e.timestamp;switch(n){case"INFO":r=R.blue(n);break;case"ERROR":r=R.red(n);break;case"WARNING":r=R.yellow(n);break;default:r=n}var a="".concat(o," ").concat(r,": ").concat(t.trim());process.stdout.write("\n".concat(a))},function(e){var r=e.close,t=e.reconnect;return oR(function(){var e;return oj(this,function(n){switch(n.label){case 0:return[4,r()];case 1:return n.sent(),[4,f("The connection to the logs server was closed. Press Enter to reconnect...")];case 2:return n.sent(),[4,rr("Connecting to log server...","Connected to log server",function(){return t()})];case 3:return O(e=n.sent())&&(t1(e.error),process.exit(2)),[2]}})})()})]})})()}).finally(function(){l.close()})];case 7:return O(p=b.sent())&&(t1(p.error),process.exit(2)),d=!1,h=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return oR(function(){return oj(this,function(r){switch(r.label){case 0:if(d)return[2];d=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,p.value.unsubscribe()];case 2:return r.sent(),[3,5];case 3:return r.sent(),e=Math.min(e,1),[3,5];case 4:return process.exit(e),[7];case 5:return[2]}})})()},["SIGINT","SIGTERM"].forEach(function(e){return process.on(e,function(){return oR(function(){return oj(this,function(e){return[2,h(0)]})})()})}),process.on("beforeExit",function(e){return oR(function(){return oj(this,function(r){switch(r.label){case 0:return[4,h(e)];case 1:return r.sent(),[2]}})})()}),process.on("uncaughtException",function(e){return oR(function(){return oj(this,function(r){switch(r.label){case 0:return process.stderr.write(R.red("Uncaught exception: ".concat(e,"\n"))),[4,h(1)];case 1:return r.sent(),[2]}})})()}),process.on("unhandledRejection",function(e){return oR(function(){return oj(this,function(r){switch(r.label){case 0:return process.stderr.write(R.red("Unhandled rejection: ".concat(e,"\n"))),[4,h(1)];case 1:return r.sent(),[2]}})})()}),[4,new Promise(function(){})];case 8:return b.sent(),[2]}})})()});function oD(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function oC(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){oD(a,n,o,i,c,"next",e)}function c(e){oD(a,n,o,i,c,"throw",e)}i(void 0)})}}function oF(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function oL(e){return oC(function(){return oF(this,function(r){switch(r.label){case 0:return[4,rr("Loading versions...","Versions loaded",function(){return oC(function(){return oF(this,function(r){switch(r.label){case 0:return[4,tq.fetchVersions(e.app_id)];case 1:return[2,r.sent()]}})})()})];case 1:return[2,r.sent()]}})})()}function oU(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function oM(){var e;return(e=function(){var e,r,t,n,o,a,i;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(c){switch(c.label){case 0:if("true"===(r=null!=(e=process.env.ATTIO_COVERAGE)?e:"").toLowerCase()||"1"===r)return[2,w({code:"COVERAGE_ENABLED_IN_PRODUCTION"})];return[4,rQ("in-memory")];case 1:if(O(t=c.sent()))return[2,w({code:"ERROR_PREPARING_BUILD_CONTEXT",error:t.error})];return[4,(n=t.value).rebuild()];case 2:if(O(o=c.sent()))return[2,w({code:"ERROR_BUILDING_BUNDLE",error:o.error})];return a=o.value,[4,n.dispose(1e3)];case 3:if(O(i=c.sent()))return[2,w({code:"ERROR_DISPOSING_BUILD_CONTEXT",error:i.error})];return[2,m([a.client.outputFiles[0].text,a.server.outputFiles[0].text])]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){oU(a,n,o,i,c,"next",e)}function c(e){oU(a,n,o,i,c,"throw",e)}i(void 0)})})()}function oG(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function oB(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function oV(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){oB(a,n,o,i,c,"next",e)}function c(e){oB(a,n,o,i,c,"throw",e)}i(void 0)})}}function oW(e,r){if(e){if("string"==typeof e)return oG(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return oG(e,r)}}function oJ(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var oY=b.object({app:b.string().optional()}),oK=new d("create").description("Create a new unpublished version of your Attio app").addOption(new h("-a, --app <slug>","The app slug to use (overrides package.json)")).action(function(e){return oV(function(){var r,t,n,o,a,i,c,s,u,l,f,p,d,h,b,y,w;return oJ(this,function(g){switch(g.label){case 0:return[4,e0()];case 1:return O(g.sent())&&e2(),[4,np.ensureAuthed()];case 2:if(g.sent(),!(r=oY.parse(e).app))return[3,3];return n=m(r),[3,5];case 3:return[4,nA()];case 4:n=g.sent(),g.label=5;case 5:return O(t=n)&&(tz(t.error),process.exit(1)),[4,nI(t.value)];case 6:return O(o=g.sent())&&(tX(o.error),process.exit(1)),a=o.value,[4,rr("Bundling JavaScript...","Bundling complete",oM)];case 7:var E;return O(i=g.sent())&&("COVERAGE_ENABLED_IN_PRODUCTION"===i.error.code?process.stderr.write("".concat(R.red("✖ "),"ATTIO_COVERAGE must not be set when creating production versions.\n")+" Unset the environment variable and try again.\n"):"ERROR_BUILDING_BUNDLE"===i.error.code?"BUILD_JAVASCRIPT_ERROR"===(c=i.error.error).code?(s=c.errors,u=c.warnings,null==s||s.forEach(function(e){return rf(e,"error")}),null==u||u.forEach(function(e){return rf(e,"warning")})):rZ(c):rZ(i.error.error),process.exit(1)),E=i.value,f=(l=function(e){if(Array.isArray(e))return e}(E)||function(e,r){var t,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(t=o.next()).done)&&(a.push(t.value),a.length!==r);i=!0);}catch(e){c=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw n}}return a}}(E,2)||oW(E,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],p=l[1],[4,oL(a)];case 8:return O(d=g.sent())&&(t$("Error fetching versions",d.error),process.exit(1)),h=d.value,[4,rr("Uploading...","Upload complete",function(){return oV(function(){var e,r,t,n,o,i,c,s;return oJ(this,function(u){switch(u.label){case 0:var l;return O(r=nP())&&(tQ(r),process.exit(1)),t=r.value,[4,tq.createVersion({appId:a.app_id,major:0===h.length?1:(e=Math).max.apply(e,((function(e){if(Array.isArray(e))return oG(e)})(l=h.map(function(e){return e.major}))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(l)||oW(l)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([1])),cliVersion:t})];case 1:return O(n=u.sent())&&(t$("Error creating version",n.error),process.exit(1)),i=(o=n.value).client_bundle_upload_url,c=o.server_bundle_upload_url,[4,v([nH(f,i),nH(p,c)])];case 2:return O(s=u.sent())&&(process.stderr.write("".concat(R.red("✖ "),"Failed to upload bundle to: ").concat(s.error.upload_url,"\n")),process.exit(1)),[2,n]}})})()})];case 9:return O(b=g.sent())&&(process.stderr.write("".concat(R.red("✖ "),"Failed to create version: ").concat(b.error,"\n")),process.exit(1)),y=b.value,[4,rr("Signing bundles...","Bundles signed",function(){return oV(function(){return oJ(this,function(e){switch(e.label){case 0:return[4,tq.completeProdBundleUpload({appId:a.app_id,major:y.major,minor:y.minor,bundleId:y.app_prod_version_bundle_id})];case 1:return[2,e.sent()]}})})()})];case 10:return O(w=g.sent())&&(t$("Error signing bundles",w.error),process.exit(1)),process.stdout.write("\nVersion ".concat(R.green("".concat(y.major,".").concat(y.minor))," created!\n\n")),process.exit(0),[2]}})})()});function oH(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var oq=b.object({app:b.string().optional()}),o$=new d().name("list").description("List all versions of your app").addOption(new h("-a, --app <slug>","The app slug to use (overrides package.json)")).action(function(e){var r;return(r=function(){var r,t,n,o,a,i,c;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(s){switch(s.label){case 0:return[4,np.ensureAuthed()];case 1:if(s.sent(),!(r=oq.parse(e).app))return[3,2];return n=m(r),[3,4];case 2:return[4,nA()];case 3:n=s.sent(),s.label=4;case 4:return O(t=n)&&(tz(t.error),process.exit(1)),[4,nI(t.value)];case 5:return O(o=s.sent())&&(tX(o.error),process.exit(1)),[4,oL(o.value)];case 6:return O(a=s.sent())&&(t$("Error loading versions",a.error),process.exit(1)),0===(i=a.value).length&&(process.stdout.write("No versions found\n"),process.exit(0)),c=new ed({head:["Version","Status","Published","Installations","Created"].map(function(e){return R.bold(e)}),style:{head:[],border:[]},colAligns:["center","left","center","right","left"]}),i.forEach(function(e){var r={private:R.gray,"in-review":R.yellow,published:R.green,rejected:R.red},t=e.publication_status.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join(" ");c.push(["".concat(e.major,".").concat(e.minor),r[e.publication_status](t),e.is_published?"Yes":"No",e.num_installations.toLocaleString(),eh(new Date(e.created_at),"MMM d, yyyy, HH:mm")])}),process.stdout.write("\n"+c.toString()+"\n"),process.exit(0),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(e){oH(a,n,o,i,c,"next",e)}function c(e){oH(a,n,o,i,c,"throw",e)}i(void 0)})})()}),oX=new d("version").description("Manage app versions").addCommand(oK).addCommand(o$);function oz(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var oQ=new d().name("whoami").description("Identify the current user").action(function(){var e;return(e=function(){var e,r,t,n,o;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(a){switch(a.label){case 0:return[4,nc().load()];case 1:return(O(e=a.sent())||null===e.value)&&(process.stdout.write("\uD83D\uDD12 Not logged in.\n"),process.exit(0)),[4,tq.whoami()];case 2:return O(r=a.sent())&&(t$("Error fetching user",r.error),process.exit(1)),n=(t=r.value).name,o=t.email_address,process.stdout.write("\uD83D\uDC64 ".concat(n.full," (").concat(o,")\n")),process.exit(0),[2]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){oz(a,n,o,i,c,"next",e)}function c(e){oz(a,n,o,i,c,"throw",e)}i(void 0)})})()}),oZ=r(e(import.meta.url)),o0=b.object({version:b.string()}).parse(JSON.parse(s(l(oZ,"../../package.json"),"utf-8")));new d().name("attio").description("CLI tool to create Attio apps").version(o0.version).addCommand(ou).addCommand(ty).addCommand(n5).addCommand(oX).addCommand(of).addCommand(od).addCommand(oQ).addCommand(oN).parse();
|
|
2
|
+
import{fileURLToPath as e}from"node:url";import{dirname as r}from"node:path";import t,{accessSync as n,constants as o,createReadStream as a,existsSync as i,promises as c,readFileSync as s}from"fs";import u,{join as l,resolve as f}from"path";import{Argument as p,Command as d,Option as h}from"commander";import{z as b}from"zod";import{combine as y,combineAsync as v,complete as m,errored as w,fromPromise as g,fromThrowable as _,isComplete as E,isErrored as O,map as k}from"@attio/fetchable";import S from"readline/promises";import I from"fs/promises";import{Project as T,SyntaxKind as x}from"ts-morph";import A from"process";import R from"chalk";import j,{createInterface as P}from"readline";import N from"typescript";import C from"node:fs";import{parse as D}from"@typescript-eslint/parser";import{analyze as F}from"@typescript-eslint/scope-manager";import{walk as L}from"zimmerframe";import{context as U}from"esbuild";import M from"tmp-promise";import G from"@fal-works/esbuild-plugin-global-externals";import{glob as B}from"glob";import V from"chokidar";import{Kind as W,OperationTypeNode as J,buildSchema as Y,isExecutableDefinitionNode as K,parse as H}from"graphql";import{codegen as q}from"@graphql-codegen/core";import{format as $}from"prettier";import{codeFrameColumns as X}from"@babel/code-frame";import z from"node-notifier";import{createHash as Q,randomBytes as Z}from"crypto";import{serve as ee}from"@hono/node-server";import{Hono as er}from"hono";import et from"open";import en from"net";import eo from"stdin-blocker";import ea from"tiny-cursor";import{select as ei}from"@inquirer/prompts";import{findUpSync as ec}from"find-up-simple";import es from"dotenv";import{graphqlServer as eu}from"@hono/graphql-server";import el from"boxen";import ef from"node:readline/promises";import ep from"ably";import ed from"cli-table3";import{format as eh}from"date-fns";import*as eb from"@graphql-codegen/typescript-operations";var ey,ev,em,ew={},eg={};function e_(e){var r=eg[e];if(void 0!==r)return r.exports;var t=eg[e]={exports:{}};return ew[e](t,t.exports,e_),t.exports}e_.m=ew,e_.f={},e_.e=e=>Promise.all(Object.keys(e_.f).reduce((r,t)=>(e_.f[t](e,r),r),[])),e_.u=e=>""+e+".index.js",e_.o=(e,r)=>Object.prototype.hasOwnProperty.call(e,r),e_.p="",e_.rv=()=>"1.6.4",ey={889:0},ev=e=>{var r,t,n=e.__webpack_ids__,o=e.__webpack_modules__,a=e.__webpack_runtime__,i=0;for(r in o)e_.o(o,r)&&(e_.m[r]=o[r]);for(a&&a(e_);i<n.length;i++)t=n[i],e_.o(ey,t)&&ey[t]&&ey[t][0](),ey[n[i]]=0},e_.f.j=function(e,r){var t=e_.o(ey,e)?ey[e]:void 0;if(0!==t)if(t)r.push(t[1]);else{var n=import("./"+e_.u(e)).then(ev,r=>{throw 0!==ey[e]&&(ey[e]=void 0),r}),n=Promise.race([n,new Promise(r=>{t=ey[e]=[r]})]);r.push(t[1]=n)}},e_.ruid="bundler=rspack@1.6.4";var eE=["recordAction","bulkRecordAction","recordWidget","callRecordingInsightTextSelectionAction","callRecordingSummaryTextSelectionAction","callRecordingTranscriptTextSelectionAction","workspaceSettings","workflowBlock"];function eO(e){return e.charAt(0).toUpperCase()+e.slice(1)}var ek="\nexport interface ".concat(eO("recordAction")," {\n id: string\n label: string\n icon: string\n onTrigger: (record: {recordId: string; object: string}) => void | Promise<void>\n objects?: ObjectSlug | Array<ObjectSlug> | ((attributes: Array<Attribute>) => boolean)\n}\n"),eS="\nexport interface ".concat(eO("bulkRecordAction")," {\n id: string\n label: string\n icon: string\n onTrigger: (record: {recordIds: Array<string>; object: string}) => void | Promise<void>\n objects?: ObjectSlug | Array<ObjectSlug> | ((attributes: Array<Attribute>) => boolean)\n}\n"),eI="\nexport interface ".concat(eO("recordWidget")," {\n id: string\n Widget: (props: {recordId: string; object: ObjectSlug}) => React.JSX.Element\n objects?: ObjectSlug | Array<ObjectSlug> | ((attributes: Array<Attribute>) => boolean)\n}\n"),eT="\nexport interface ".concat(eO("callRecordingInsightTextSelectionAction")," {\n id: string\n label: string\n icon: string\n onTrigger: (selection: {text: string; markdown: string}) => void | Promise<void>\n}\n"),ex="\nexport interface ".concat(eO("callRecordingSummaryTextSelectionAction")," {\n id: string\n label: string\n icon: string\n onTrigger: (selection: {text: string; markdown: string}) => void | Promise<void>\n}\n"),eA="\nexport interface ".concat(eO("callRecordingTranscriptTextSelectionAction")," {\n id: string\n label: string\n icon: string\n onTrigger: (selection: {transcript: Array<{speaker: string; text: string}>; url: string}) => void | Promise<void>\n}\n"),eR="\nexport interface ".concat(eO("workflowBlock")," {\n id: string\n title: string\n description: string\n configSchema: Record<string, Node> | Struct\n configurator: React.ReactNode\n}\n"),ej="\nexport interface ".concat(eO("workspaceSettings")," {\n Page: React.ComponentType<{}>\n}\n"),eP="\n".concat(ek,"\n\n").concat(eS,"\n\n").concat(eI,"\n\n").concat(eT,"\n\n").concat(ex,"\n\n").concat(eA,"\n\n").concat(ej,"\n\n").concat(eR,"\n"),eN=function(e){var r=e.getBaseName();return r.endsWith(".ts")||r.endsWith(".tsx")};function eC(e){var r,t;function n(r,t){try{var a=e[r](t),i=a.value,c=i instanceof eL;Promise.resolve(c?i.v:i).then(function(t){if(c){var s="return"===r?"return":"next";if(!i.k||t.done)return n(s,t);t=e[s](t).value}o(a.done?"return":"normal",t)},function(e){n("throw",e)})}catch(e){o("throw",e)}}function o(e,o){switch(e){case"return":r.resolve({value:o,done:!0});break;case"throw":r.reject(o);break;default:r.resolve({value:o,done:!1})}(r=r.next)?n(r.key,r.arg):t=null}this._invoke=function(e,o){return new Promise(function(a,i){var c={key:e,arg:o,resolve:a,reject:i,next:null};t?t=t.next=c:(r=t=c,n(e,o))})},"function"!=typeof e.return&&(this.return=void 0)}function eD(e){function r(e){if(Object(e)!==e)return Promise.reject(TypeError(e+" is not an object."));var r=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:r}})}return(eD=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return r(this.n.apply(this.s,arguments))},return:function(e){var t=this.s.return;return void 0===t?Promise.resolve({value:e,done:!0}):r(t.apply(this.s,arguments))},throw:function(e){var t=this.s.return;return void 0===t?Promise.reject(e):r(t.apply(this.s,arguments))}},new eD(e)}function eF(e){return new eL(e,0)}function eL(e,r){this.v=e,this.k=r}eC.prototype["function"==typeof Symbol&&Symbol.asyncIterator||"@@asyncIterator"]=function(){return this},eC.prototype.next=function(e){return this._invoke("next",e)},eC.prototype.throw=function(e){return this._invoke("throw",e)},eC.prototype.return=function(e){return this._invoke("return",e)};var eU=["js","jsx","ts","tsx"],eM=["node_modules"];function eG(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function eB(e){function r(e){if(Object(e)!==e)return Promise.reject(TypeError(e+" is not an object."));var r=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:r}})}return(eB=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return r(this.n.apply(this.s,arguments))},return:function(e){var t=this.s.return;return void 0===t?Promise.resolve({value:e,done:!0}):r(t.apply(this.s,arguments))},throw:function(e){var t=this.s.return;return void 0===t?Promise.reject(e):r(t.apply(this.s,arguments))}},new eB(e)}function eV(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function eW(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){eV(a,n,o,i,c,"next",e)}function c(e){eV(a,n,o,i,c,"throw",e)}i(void 0)})}}function eJ(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function eY(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function eK(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function eH(e){return e.replace(/[^a-zA-Z0-9]+/g," ").trim().split(" ").map(function(e,r){return 0===r?e.toLowerCase():e.charAt(0).toUpperCase()+e.slice(1).toLowerCase()}).join("")}function eq(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function e$(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){eq(a,n,o,i,c,"next",e)}function c(e){eq(a,n,o,i,c,"throw",e)}i(void 0)})}}function eX(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var ez=["ts","tsx"];function eQ(e){return e$(function(){var r;return eX(this,function(t){switch(t.label){case 0:return[4,Promise.all(ez.map(function(r){return e$(function(){var t,n;return eX(this,function(o){switch(o.label){case 0:return t=u.join(e,"app.".concat(r)),[4,g(I.readFile(t))];case 1:if(O(n=o.sent()))return[2,null];return[2,{path:t,content:n.value.toString()}]}})})()}))];case 1:return[2,null!=(r=t.sent().find(function(e){return null!==e}))?r:null]}})})()}function eZ(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function e0(){var e,r=arguments.length>0&&void 0!==arguments[0]&&arguments[0];return(e=function(){var e,t;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:return[4,eQ(e=u.resolve("src"))];case 1:if(null!==n.sent())return[2,m(!0)];if(!r)return[2,w({code:"APP_ENTRY_POINT_NOT_FOUND"})];return[4,(t=S.createInterface({input:process.stdin,output:process.stdout})).question("Could not find app.ts entry point. Press Enter to generate it...")];case 2:var o,a;return n.sent(),t.close(),[4,(o=e,(a=function(){var e,r,t,n,a,i,c,s,l,f,p,d,h,b,y,v,_,k,S,A,R;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(j){var P;switch(j.label){case 0:return[4,eW(function(){var e,r,t,n,a,i,c,s,l,f,p,d,h,b,y,v;return eJ(this,function(g){switch(g.label){case 0:e=new Set,r=new Set,t=new T({compilerOptions:{allowJs:!0},useInMemoryFileSystem:!0}),n=u.join(o,"".concat(Math.random().toString(36).slice(2),".").concat("ts")),i={recordAction:(a=t.createSourceFile(n,eP)).getInterfaceOrThrow("RecordAction").getType(),bulkRecordAction:a.getInterfaceOrThrow("BulkRecordAction").getType(),recordWidget:a.getInterfaceOrThrow("RecordWidget").getType(),callRecordingInsightTextSelectionAction:a.getInterfaceOrThrow("CallRecordingInsightTextSelectionAction").getType(),callRecordingSummaryTextSelectionAction:a.getInterfaceOrThrow("CallRecordingSummaryTextSelectionAction").getType(),callRecordingTranscriptTextSelectionAction:a.getInterfaceOrThrow("CallRecordingTranscriptTextSelectionAction").getType(),workspaceSettings:a.getInterfaceOrThrow("WorkspaceSettings").getType(),workflowBlock:a.getInterfaceOrThrow("WorkflowBlock").getType()},c=t.getTypeChecker(),s=[],l=[],f=!1,p=!1,g.label=1;case 1:g.trys.push([1,6,7,12]),h=function(e){var r,t,n,o=2;for("undefined"!=typeof Symbol&&(t=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(t&&null!=(r=e[t]))return r.call(e);if(n&&null!=(r=e[n]))return new eB(r.call(e));t="@@asyncIterator",n="@@iterator"}throw TypeError("Object is not async iterable")}(function e(r){var t;return(t=function(){var t,n,o,a,i,c,s,l,f,p,d,h,b,y,v,m,w,g,_,E,O,k;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(S){switch(S.label){case 0:return[4,eF(I.readdir(r,{withFileTypes:!0}))];case 1:t=S.sent(),n=[],o=!0,a=!1,i=void 0,S.label=2;case 2:S.trys.push([2,8,9,10]),c=t[Symbol.iterator](),S.label=3;case 3:if(o=(s=c.next()).done)return[3,7];if(l=s.value,f=u.join(r,l.name),!(l.isDirectory()&&!eM.includes(l.name)))return[3,4];return n.push(e(f)),[3,6];case 4:var T;if(T=f,!eU.some(function(e){return T.endsWith(".".concat(e))}))return[3,6];return[4,f];case 5:S.sent(),S.label=6;case 6:return o=!0,[3,3];case 7:return[3,10];case 8:return p=S.sent(),a=!0,i=p,[3,10];case 9:try{o||null==c.return||c.return()}finally{if(a)throw i}return[7];case 10:d=!0,h=!1,b=void 0,S.label=11;case 11:S.trys.push([11,27,28,29]),y=n[Symbol.iterator](),S.label=12;case 12:if(d=(v=y.next()).done)return[3,26];m=v.value,w=!1,g=!1,S.label=13;case 13:S.trys.push([13,19,20,25]),E=function(e){var r,t,n,o=2;for("undefined"!=typeof Symbol&&(t=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(t&&null!=(r=e[t]))return r.call(e);if(n&&null!=(r=e[n]))return new eD(r.call(e));t="@@asyncIterator",n="@@iterator"}throw TypeError("Object is not async iterable")}(m),S.label=14;case 14:return[4,eF(E.next())];case 15:if(!(w=!(O=S.sent()).done))return[3,18];return[4,O.value];case 16:S.sent(),S.label=17;case 17:return w=!1,[3,14];case 18:return[3,25];case 19:return k=S.sent(),g=!0,_=k,[3,25];case 20:if(S.trys.push([20,,23,24]),!(w&&null!=E.return))return[3,22];return[4,eF(E.return())];case 21:S.sent(),S.label=22;case 22:return[3,24];case 23:if(g)throw _;return[7];case 24:return[7];case 25:return d=!0,[3,12];case 26:return[3,29];case 27:return p=S.sent(),h=!0,b=p,[3,29];case 28:try{d||null==y.return||y.return()}finally{if(h)throw b}return[7];case 29:return[2]}})},function(){return new eC(t.apply(this,arguments))})()}(o)),g.label=2;case 2:return[4,h.next()];case 3:if(!(f=!(b=g.sent()).done))return[3,5];y=b.value,s.push(eW(function(){var e,r;return eJ(this,function(n){switch(n.label){case 0:return n.trys.push([0,2,,3]),[4,I.readFile(y,"utf-8")];case 1:return e=n.sent(),[2,m(t.createSourceFile(y,e,{overwrite:!0}))];case 2:if((void 0===(r=n.sent())?"undefined":r&&"undefined"!=typeof Symbol&&r.constructor===Symbol?"symbol":typeof r)=="object"&&null!==r&&"code"in r&&"ENOENT"===r.code)return[2,w({code:"FILE_NOT_FOUND"})];return[2,w({code:"UNKNOWN_ERROR"})];case 3:return[2]}})})()),g.label=4;case 4:return f=!1,[3,2];case 5:return[3,12];case 6:return v=g.sent(),p=!0,d=v,[3,12];case 7:if(g.trys.push([7,,10,11]),!(f&&null!=h.return))return[3,9];return[4,h.return()];case 8:g.sent(),g.label=9;case 9:return[3,11];case 10:if(p)throw d;return[7];case 11:return[7];case 12:return[4,Promise.all(s)];case 13:return g.sent().filter(function(e){return E(e)}).map(function(t){var n=function(e){var r=e.sourceFile,t=e.existingExportSymbols,n=e.existingIds,o=e.typeChecker,a=e.surfaceTypes,i=new Set,c=r.getFilePath(),s=r.getExportedDeclarations(),u=!0,l=!1,f=void 0;try{for(var p,d=eE[Symbol.iterator]();!(u=(p=d.next()).done);u=!0)!function(){var e,u,l=p.value,f=s.get(l);if(!f)return;var d=f[0],h=null!=(u=(e=d.getSymbol())&&o.getAliasedSymbol(e))?u:e;if(!(!h||t.has(h))){var b=d.getType();if(eN(r)&&!o.isTypeAssignableTo(b,a[l])){var y=d.getFirstChild()||d;throw{errors:[{text:"".concat(l," in ").concat(c," is not assignable to ").concat(eO(l)),location:{file:c,line:y.getStartLineNumber(),column:0,lineText:d.getText().split("\n")[0],additionalLines:d.getText().split("\n").slice(1),length:y.getWidth(),namespace:l,suggestion:"Ensure the export matches the type ".concat(eO(l))}}]}}var v=function(e){if(d.getKind()!==x.VariableDeclaration)throw Error("".concat(l," is not an object in ").concat(c," ").concat(d.getKind()));var r=d.asKindOrThrow(x.VariableDeclaration).getInitializer();if((null==r?void 0:r.getKind())!==x.ObjectLiteralExpression)throw Error("".concat(l," must be defined as an object literal expression in ").concat(c));var t=r.asKindOrThrow(x.ObjectLiteralExpression).getProperty("id");if((null==t?void 0:t.getKind())!==x.PropertyAssignment)throw Error("Property ".concat("id"," on ").concat(l," must be directly declared in the object declaration in ").concat(c));var n=t.asKindOrThrow(x.PropertyAssignment).getInitializer();if((null==n?void 0:n.getKind())!==x.StringLiteral)throw Error("Property ".concat("id"," on ").concat(l," must be a string literal in ").concat(c));return n.asKindOrThrow(x.StringLiteral).getLiteralValue()}(0);if(n.has(v))throw{errors:[{text:"Duplicate surface id ".concat(v),location:{file:c,line:d.getStartLineNumber(),column:0,length:d.getWidth(),lineText:d.getText().split("\n")[0],additionalLines:d.getText().split("\n").slice(1),namespace:l,suggestion:"Ensure the id is unique"}}]};t.add(h),n.add(v),i.add({surfaceType:l,id:v})}}()}catch(e){l=!0,f=e}finally{try{u||null==d.return||d.return()}finally{if(l)throw f}}return i}({sourceFile:t.value,existingExportSymbols:e,existingIds:r,typeChecker:c,surfaceTypes:i});n.size>0&&l.push([t.value.getFilePath(),function(e){if(Array.isArray(e))return eG(e)}(n)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(n)||function(e,r){if(e){if("string"==typeof e)return eG(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return eG(e,void 0)}}(n)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()])}),[2,l]}})})()];case 1:e=j.sent(),r=eE.reduce(function(e,r){return e[r]=[],e},{}),t=!0,n=!1,a=void 0;try{for(i=e[Symbol.iterator]();!(t=(c=i.next()).done);t=!0){P=c.value,l=(s=function(e){if(Array.isArray(e))return e}(P)||function(e,r){var t,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(t=o.next()).done)&&(a.push(t.value),2!==a.length);i=!0);}catch(e){c=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw n}}return a}}(P,2)||function(e,r){if(e){if("string"==typeof e)return eY(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return eY(e,2)}}(P,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],f=s[1],p=!0,d=!1,h=void 0;try{for(b=f[Symbol.iterator]();!(p=(y=b.next()).done);p=!0)r[(v=y.value).surfaceType].push({importPath:function(e,r){var t=u.relative(e,r).split(u.sep).join("/").replace(/\.[^/.]+$/,"");return t.startsWith(".")?t:"./".concat(t)}(o,l),id:v.id})}catch(e){d=!0,h=e}finally{try{p||null==b.return||b.return()}finally{if(d)throw h}}}}catch(e){n=!0,a=e}finally{try{t||null==i.return||i.return()}finally{if(n)throw a}}return _=eE.flatMap(function(e){return r[e].map(function(r){var t=eH(r.id);return"import {".concat(e).concat(t!==e?" as ".concat(t):"","} from ").concat(JSON.stringify(r.importPath))})}).join("\n"),S=(k=eE.reduce(function(e,t){return e[t]=r[t].map(function(e){return eH(e.id)}),e},{})).callRecordingInsightTextSelectionAction.length>0||k.callRecordingSummaryTextSelectionAction.length>0||k.callRecordingTranscriptTextSelectionAction.length>0,A=['import type {App} from "attio"\n',_,"\nexport const app: App = {\n record: {\n actions: [".concat(k.recordAction.join(", "),"],\n bulkActions: [").concat(k.bulkRecordAction.join(", "),"],").concat(k.recordWidget.length>0?"\n widgets: [".concat(k.recordWidget.join(", "),"],"):"","\n },").concat(S?"\n callRecording: {\n insight: {\n textActions: [".concat(k.callRecordingInsightTextSelectionAction.join(", "),"],\n },\n summary: {\n textActions: [").concat(k.callRecordingSummaryTextSelectionAction.join(", "),"],\n },\n transcript: {\n textActions: [").concat(k.callRecordingTranscriptTextSelectionAction.join(", "),"],\n },\n },"):"","\n}\n")].join("\n"),[4,g(I.writeFile(u.join(o,"app.ts"),A))];case 2:if(O(R=j.sent()))return[2,R];return[2,m(!0)]}})},function(){var e=this,r=arguments;return new Promise(function(t,n){var o=a.apply(e,r);function i(e){eK(o,t,n,i,c,"next",e)}function c(e){eK(o,t,n,i,c,"throw",e)}i(void 0)})})())];case 3:if(O(n.sent()))return[2,w({code:"FAILED_TO_GENERATE_ENTRY_POINT"})];return[2,m(!0)]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){eZ(a,n,o,i,c,"next",e)}function c(e){eZ(a,n,o,i,c,"throw",e)}i(void 0)})})()}function e1(e){A.stderr.write(R.red("✖ "+e)+"\n"),A.exit(1)}function e2(){var e,r,t,n;e1("Could not find app.ts. Run `".concat(null!=(t=({npm:"npm run ".concat("dev"),yarn:"yarn ".concat("dev"),pnpm:"pnpm ".concat("dev"),bun:"bun run ".concat("dev")})[null!=(n=null==(r=process.env.npm_config_user_agent)||null==(e=r.split("/"))?void 0:e[0])?n:"npm"])?t:"npm run ".concat("dev"),"` to generate it. See https://docs.attio.com/sdk/guides/app-ts-migration"))}var e4=".attio",e3="app.settings.ts";function e6(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function e5(){var e;return(e=function(){var e,r,t;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:e=u.resolve("."),r=u.join(e,e4),t=u.join(r,"settings.d.ts"),n.label=1;case 1:return n.trys.push([1,4,,5]),[4,I.mkdir(r,{recursive:!0})];case 2:return n.sent(),[4,I.writeFile(t,'import "attio"\n\nimport type appSettingsSchema from "../src/app.settings"\n\ndeclare module "attio" {\n export interface AppSettingsSchema {\n workspace: (typeof appSettingsSchema)["workspace"]\n }\n}\n')];case 3:return n.sent(),[2,m(void 0)];case 4:return n.sent(),[2,w({code:"FAILED_TO_CREATE_SETTINGS_TYPES_FILE"})];case 5:return[2]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){e6(a,n,o,i,c,"next",e)}function c(e){e6(a,n,o,i,c,"throw",e)}i(void 0)})})()}function e7(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function e8(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var e9=["⠋","⠙","⠹","⠸","⠼","⠴","⠦","⠧","⠇","⠏"],re=function(){"use strict";var e;function r(){if(!(this instanceof r))throw TypeError("Cannot call a class as a function");e8(this,"frameIndex",0),e8(this,"stopped",!1),e8(this,"interval",null),e8(this,"message","")}return e=[{key:"start",value:function(e){var r=this;return this.interval&&clearInterval(this.interval),this.message=e,this.stopped=!1,this.interval=setInterval(function(){if(!r.stopped){var e=e9[r.frameIndex=++r.frameIndex%e9.length];process.stdout.write("\r".concat(e," ").concat(r.message))}},80),this}},{key:"update",value:function(e){return this.message=e,this}},{key:"stop",value:function(e){return this.stopped=!0,this.interval&&(clearInterval(this.interval),this.interval=null),e&&process.stdout.write("\r".concat(e," \n")),this}},{key:"success",value:function(e){return this.stop("".concat(R.green("✓")," ").concat(e))}},{key:"error",value:function(e){return this.stop("".concat(R.red("✖")," ").concat(e))}},{key:"warning",value:function(e){return this.stop("".concat(R.yellow("⚠")," ").concat(e))}}],function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,e),r}();function rr(e,r,t){var n;return(n=function(){var n,o;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(a){switch(a.label){case 0:(n=new re).start(e),a.label=1;case 1:return a.trys.push([1,,3,4]),[4,t()];case 2:return E(o=a.sent())&&n.success("string"==typeof r?r:r(o.value)),[2,o];case 3:return n.stop(),[7];case 4:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(t,o){var a=n.apply(e,r);function i(e){e7(a,t,o,i,c,"next",e)}function c(e){e7(a,t,o,i,c,"throw",e)}i(void 0)})})()}function rt(e){function r(e){if(Object(e)!==e)return Promise.reject(TypeError(e+" is not an object."));var r=e.done;return Promise.resolve(e.value).then(function(e){return{value:e,done:r}})}return(rt=function(e){this.s=e,this.n=e.next}).prototype={s:null,n:null,next:function(){return r(this.n.apply(this.s,arguments))},return:function(e){var t=this.s.return;return void 0===t?Promise.resolve({value:e,done:!0}):r(t.apply(this.s,arguments))},throw:function(e){var t=this.s.return;return void 0===t?Promise.reject(e):r(t.apply(this.s,arguments))}},new rt(e)}function rn(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function ro(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){rn(a,n,o,i,c,"next",e)}function c(e){rn(a,n,o,i,c,"throw",e)}i(void 0)})}}function ra(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var ri={getCanonicalFileName:function(e){return e},getCurrentDirectory:N.sys.getCurrentDirectory,getNewLine:function(){return"\n"}},rc=b.object({text:b.string(),location:b.object({file:b.string(),lineText:b.string(),line:b.number(),character:b.number(),endCharacter:b.number()}).optional()}),rs=function(e){return ro(function(){return ra(this,function(r){return[2,new Promise(function(r,t){if(!i(e))return void r("Not a TypeScript project");var n=N.readConfigFile(e,N.sys.readFile),o=n.config,a=n.error;if(a)t(rc.parse({text:N.formatDiagnostic(a,ri)}));else{var c=N.parseJsonConfigFileContent(o,N.sys,"./");r(N.createProgram({rootNames:c.fileNames,options:c.options}))}})]})})()},ru=function(e){return ro(function(){return ra(this,function(r){switch(r.label){case 0:return[4,Promise.all(N.getPreEmitDiagnostics(e).map(function(e){return ro(function(){var r,t,n,o,i,c,s;return ra(this,function(u){switch(u.label){case 0:var l,f;if(r=N.flattenDiagnosticMessageText(e.messageText,"\n"),!e.file)return[3,2];return n=(t=e.file.getLineAndCharacterOfPosition(e.start)).line,o=t.character,i=e.start+e.length,c=e.file.getLineAndCharacterOfPosition(i).character,[4,(l=e.file.fileName,f=n,ro(function(){var e,r,t,n,o,i,c,s,u,p;return ra(this,function(d){switch(d.label){case 0:r=P({input:e=a(l),crlfDelay:1/0}),t=0,n=!1,o=!1,d.label=1;case 1:d.trys.push([1,6,7,12]),c=function(e){var r,t,n,o=2;for("undefined"!=typeof Symbol&&(t=Symbol.asyncIterator,n=Symbol.iterator);o--;){if(t&&null!=(r=e[t]))return r.call(e);if(n&&null!=(r=e[n]))return new rt(r.call(e));t="@@asyncIterator",n="@@iterator"}throw TypeError("Object is not async iterable")}(r),d.label=2;case 2:return[4,c.next()];case 3:if(!(n=!(s=d.sent()).done))return[3,5];if(u=s.value,(t+=1)===f+1)return r.close(),e.close(),[2,u];d.label=4;case 4:return n=!1,[3,2];case 5:return[3,12];case 6:return p=d.sent(),o=!0,i=p,[3,12];case 7:if(d.trys.push([7,,10,11]),!(n&&null!=c.return))return[3,9];return[4,c.return()];case 8:d.sent(),d.label=9;case 9:return[3,11];case 10:if(o)throw i;return[7];case 11:return[7];case 12:return[2,null]}})})())];case 1:return s=u.sent(),[2,rc.parse({text:r,location:{file:e.file.fileName,line:n,character:o,endCharacter:c,lineText:s}})];case 2:return[2,rc.parse({text:r})];case 3:return[2]}})})()}))];case 1:return[2,r.sent()]}})})()};function rl(e){if(!e.location)return void process.stderr.write("".concat(R.red("\xd7")," – ").concat(e.text,"\n"));var r,t=e.location.line.toLocaleString().padStart(3," "),n=t.length,o=" ".repeat(n),a=e.location.lineText,i=(null==(r=a.match(/^\s*/))?void 0:r[0].length)||0,c=a.trimStart(),s=c.slice(0,e.location.character-i),u=c.slice(e.location.character-i,e.location.endCharacter-i),l=c.slice(e.location.endCharacter-i);process.stderr.write("".concat(" ".repeat(n-2)," ").concat(R.red("\xd7")," ").concat(e.text,"\n\n")),process.stderr.write("".concat(o," ╭─── ").concat(R.bold(e.location.file),"\n")),process.stderr.write("".concat(t," │ ").concat(s).concat(R.red(u)).concat(l,"\n")),process.stderr.write("".concat(o," │ ").concat(" ".repeat(Math.max(0,e.location.character-i))).concat(R.red("~".repeat(Math.max(0,e.location.endCharacter-e.location.character))),"\n")),process.stderr.write("".concat(o," ╰───\n\n"))}function rf(e,r){if(!e.location)return void process.stderr.write("".concat(R.red("\xd7")," – ").concat(e.text,"\n"));var t,n=e.location.line.toLocaleString().padStart(3," "),o=n.length,a=" ".repeat(o),i=e.location.lineText,c=(null==(t=i.match(/^\s*/))?void 0:t[0].length)||0,s=i.trimStart(),u=s.slice(0,e.location.column-c),l=s.slice(e.location.column-c,e.location.column+e.location.length-c),f=s.slice(e.location.column+e.location.length-c);process.stderr.write("".concat(" ".repeat(o-2)," ").concat("error"===r?R.red("\xd7"):"\uD83D\uDEA7"," ").concat(e.text,"\n\n")),process.stderr.write("".concat(a," ╭─── ").concat(R.bold(e.location.file),"\n")),process.stderr.write("".concat(n," │ ").concat(u).concat(R.red(l)).concat(f,"\n")),process.stderr.write("".concat(a," │ ").concat(" ".repeat(Math.max(0,e.location.column-c))).concat(R.red("~".repeat(e.location.length)),"\n")),process.stderr.write("".concat(a," ╰───\n\n"))}function rp(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function rd(e,r){return r(e)?e:null}function rh(e,r){return rd(e+".ts",r)||rd(e+".tsx",r)||rd(e+".js",r)}function rb(e,r,t){var n=rh(rv(e,r),t.doesModuleExist);if(!n)throw Error("Unable to resolve path for module ".concat(e," from ").concat(r));var o=t.modules;if(o.has(n))return o.get(n);var a=t.getModuleSource(n),i=D(a,{range:!0,jsx:!0}),c=F(i,{sourceType:"module"}).acquire(i,!0),s=new Map,u={content:a,ast:i,scope:c,namedExports:s,path:n};return o.set(n,u),L(i,null,{ExportNamedDeclaration:function(e){var r;if((null==(r=e.declaration)?void 0:r.type)==="VariableDeclaration"&&1===e.declaration.declarations.length&&"VariableDeclarator"===e.declaration.declarations[0].type&&"Identifier"===e.declaration.declarations[0].id.type){var t=e.declaration.declarations[0],n=t.id,o=t.init;if((null==o?void 0:o.type)==="Identifier"){var a=ry(o,c);if((null==a?void 0:a.type)!=="ImportBinding")return void s.set(n.name,t.init)}s.set(n.name,t.init)}if(null==e?void 0:e.specifiers){var i=!0,u=!1,l=void 0;try{for(var f,p=e.specifiers[Symbol.iterator]();!(i=(f=p.next()).done);i=!0){var d=f.value;if("ExportSpecifier"===d.type&&"Identifier"===d.exported.type&&"Identifier"===d.local.type)if(null!==e.source)s.set(d.exported.name,e);else{var h=ry(d.local,c);s.set(d.exported.name,h)}}}catch(e){u=!0,l=e}finally{try{i||null==p.return||p.return()}finally{if(u)throw l}}}}}),u}function ry(e,r){var t=r.set.get(e.name);if(!t)throw Error("Unable to find variable ".concat(e.name," in scope"));if(1!==t.defs.length)throw Error("Expected exactly one definition for variable ".concat(e.name,", found ").concat(t.defs.length));var n=t.defs[0];return"VariableDeclarator"===n.node.type?n.node.init:"ImportBinding"==n.type?n:null}function rv(e,r){if(e.startsWith(".")){var t=(r.split("/").slice(0,-1).join("/")+"/"+e).split("/"),n=[],o=!0,a=!1,i=void 0;try{for(var c,s=t[Symbol.iterator]();!(o=(c=s.next()).done);o=!0){var u=c.value;".."===u?n.pop():"."!==u&&n.push(u)}}catch(e){a=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}return n.join("/")}return e}function rm(e,r,t,n,o){var a="Identifier"===r.type?ry(r,t):r;if(!a||"ImportBinding"!==a.type&&"ExportNamedDeclaration"!==a.type)throw Error("Expected parent of import binding to be an import binding");var i=("ExportNamedDeclaration"===a.type?a:a.parent).source.value,c=rv(i,n);if(i.endsWith(".server"))throw Error('Unexpected .server import, did you mean to import "'.concat(e,'" from a .block file?'));if(!i.endsWith(".block")&&!i.endsWith(".block.ts")&&!i.endsWith(".block.tsx")&&!i.endsWith(".block.js")){var s=rb(i,c,o);if(!s.namedExports.has(e))throw Error("Unable to find named export ".concat(e," in module ").concat(i));var u=s.namedExports.get(e);return rm(e,u,s.scope,s.path,o)}var l=e;return"ImportBinding"===a.type&&a.name.name!==e&&(l=a.name.name),{path:c=rh(c,o.doesModuleExist)||c,export:l}}function rw(e,r,t,n,o){if("Identifier"===e.type){var a=r,i=ry(e,r),c=n;if((null==i?void 0:i.type)==="ImportBinding"){var s=i.parent,u=rb(s.source.value,n,o),l=i.name.name,f=s.specifiers.find(function(e){return e.local.name===l}),p=(null==f?void 0:f.imported).name;if(!u.namedExports.has(p))throw Error("Unable to find named export ".concat(p," in module ").concat(s.source.value));i=u.namedExports.get(p),a=u.scope,c=u.path}if(!i||"ObjectExpression"!==i.type)throw Error("Expected variable ".concat(e.name," to have an initializer"));rw(i,a,t,c,o);return}if("ObjectExpression"===e.type){var d=!0,h=!1,b=void 0;try{for(var y,v,m,w,g,_,E,O,k=e.properties[Symbol.iterator]();!(d=(O=k.next()).done);d=!0){var S=O.value;if("Property"===S.type&&"Identifier"===S.key.type){var I=S.key.name;if("id"===I){if("Literal"!==S.value.type||"string"!=typeof S.value.value)throw Error("Expected block id to be a string literal");y=S.value.value}else"execute"===I?v=rm(I,S.value,r,n,o):"deferCallback"===I?m=rm(I,S.value,r,n,o):"schema"===I?w=rm(I,S.value,r,n,o):"activate"===I?g=rm(I,S.value,r,n,o):"triggerCallback"===I?_=rm(I,S.value,r,n,o):"deactivate"===I&&(E=rm(I,S.value,r,n,o))}}}catch(e){h=!0,b=e}finally{try{d||null==k.return||k.return()}finally{if(h)throw b}}if(!y||!w)throw Error("Expected block to have id and schema properties");t.set(y,{execute:v,deferCallback:m,schema:w,activate:g,triggerCallback:_,deactivate:E})}}function rg(e,r,t){var n=e.properties.find(function(e){return"Property"===e.type&&"Identifier"===e.key.type&&e.key.name===r});if(!n)return null;var o=n.value;if("Identifier"===o.type){var a=ry(o,t);a&&(null==a?void 0:a.type)!=="ImportBinding"&&(o=a)}return o}function r_(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function rE(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var rO="proxy-block-modules-plugin";function rk(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var rS="proxy-server-modules-plugin";function rI(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var rT=b.object({text:b.string(),location:b.object({column:b.number(),file:b.string(),length:b.number(),line:b.number(),lineText:b.string(),additionalLines:b.array(b.string()).optional(),namespace:b.string(),suggestion:b.string()})}),rx=b.object({errors:b.array(rT).optional().readonly(),warnings:b.array(rT).optional().readonly()});function rA(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function rR(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){rA(a,n,o,i,c,"next",e)}function c(e){rA(a,n,o,i,c,"throw",e)}i(void 0)})}}function rj(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function rP(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function rN(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var rC=function(){"use strict";var e,r;function t(e){var r=e.tempFile,n=e.directories,o=e.workflowBlockModulesRef,a=e.esbuildContext;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");rP(this,"_lastJs",void 0),rP(this,"_esbuildContext",void 0),rP(this,"_tempFile",void 0),rP(this,"_directories",void 0),rP(this,"_workflowBlockModulesRef",void 0),this._esbuildContext=a,this._tempFile=r,this._workflowBlockModulesRef=o,this._directories=n}return e=[{key:"rebuild",value:function(e){return rR(function(e){var r,t,n,o,a,i,c,s;return rN(this,function(l){switch(l.label){case 0:return r=e.workflowBlockModules,this._workflowBlockModulesRef.current=r,[4,function(e){var r;return(r=function(e){var r,t,n,o;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(a){switch(a.label){case 0:return[4,eQ(r=e.srcDirAbsolute)];case 1:if(!(t=a.sent()))return[2,w({code:"APP_ENTRY_POINT_NOT_FOUND"})];if(!new T({useInMemoryFileSystem:!0}).createSourceFile(t.path,t.content).getExportedDeclarations().has("app"))return[2,w({code:"APP_EXPORT_NOT_FOUND",path:t.path})];return[4,g(I.readFile(u.join(r,e3)))];case 2:return n=E(a.sent())?"\n import appSettingsSchema from ".concat(JSON.stringify(u.join(r,e3)),"\n\n registerSettingsSchema(appSettingsSchema)\n "):"\n registerSettingsSchema({workspace: {}})\n ",o="\n import {app} from ".concat(JSON.stringify(t.path),"\n "),[2,m("\n ".concat(o,"\n\n ").concat(n,"\n\n ").concat('\n const recordActions = app?.record?.actions\n const bulkRecordActions = app?.record?.bulkActions\n const recordWidgets = app?.record?.widgets\n const callRecordingInsights = app?.callRecording?.insight?.textActions\n const callRecordingSummaries = app?.callRecording?.summary?.textActions\n const callRecordingTranscripts = app?.callRecording?.transcript?.textActions\n const workflowStepBlocks = app?.workflow?.blocks?.steps\n const workflowTriggerBlocks = app?.workflow?.blocks?.triggers\n const workspaceSettings = app?.settings?.workspace\n\n registerSurfaces({\n "record-action": Array.isArray(recordActions) ? recordActions : [],\n "bulk-record-action": Array.isArray(bulkRecordActions) ? bulkRecordActions : [],\n "record-widget": Array.isArray(recordWidgets) ? recordWidgets : [],\n "call-recording-insight-text-selection-action": Array.isArray(callRecordingInsights) ? callRecordingInsights : [],\n "call-recording-summary-text-selection-action": Array.isArray(callRecordingSummaries) ? callRecordingSummaries : [],\n "call-recording-transcript-text-selection-action": Array.isArray(callRecordingTranscripts) ? callRecordingTranscripts : [],\n "workflow-block": [\n ...(Array.isArray(workflowStepBlocks)\n ? workflowStepBlocks.map((block) => ({type: "step", id: block.id, block}))\n : []),\n ...(Array.isArray(workflowTriggerBlocks)\n ? workflowTriggerBlocks.map((block) => ({type: "trigger", id: block.id, block}))\n : []),\n ],\n "workspace-settings": workspaceSettings ? [workspaceSettings] : [],\n })\n ',"\n "))]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(e){rI(a,n,o,i,c,"next",e)}function c(e){rI(a,n,o,i,c,"throw",e)}i(void 0)})}).apply(this,arguments)}({srcDirAbsolute:u.resolve(this._directories.src)})];case 1:if(O(t=l.sent()))return[2,t];if((n=t.value)===this._lastJs)return[3,5];l.label=2;case 2:return l.trys.push([2,4,,5]),[4,I.writeFile(this._tempFile.path,n)];case 3:return l.sent(),this._lastJs=n,[3,5];case 4:return o=l.sent(),[2,w({code:"FAILED_TO_CREATE_TEMP_FILE",path:this._tempFile.path,error:o})];case 5:return l.trys.push([5,7,,8]),[4,this._esbuildContext.rebuild()];case 6:return[2,m.apply(void 0,[l.sent()])];case 7:if(a=l.sent(),!(i=rx.safeParse(a)).success)return[2,w({code:"UNPARSABLE_BUILD_ERROR",error:a})];return[2,w({code:"BUILD_JAVASCRIPT_ERROR",errors:null!=(c=i.data.errors)?c:[],warnings:null!=(s=i.data.warnings)?s:[]})];case 8:return[2]}})}).apply(this,arguments)}},{key:"dispose",value:function(e){return rR(function(){return rN(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,Promise.race([Promise.all([this._esbuildContext.dispose(),this._tempFile.cleanup()]),new Promise(function(r,t){return setTimeout(function(){return t(Error("Context disposal timeout"))},e)})])];case 1:return r.sent(),[3,3];case 2:return[2,w({code:"FAILED_TO_DISPOSE_OF_BUILD_CONTEXT",error:r.sent()})];case 3:return[2,m(void 0)]}})}).call(this)}}],r=[{key:"create",value:function(e){return rR(function(e){var r,n,o,a,i,c;return rN(this,function(s){switch(s.label){case 0:r=e.outfile,n=e.directories,o=e.mode,s.label=1;case 1:return s.trys.push([1,4,,5]),a={current:new Map},[4,M.file({postfix:".js"})];case 2:var l,f;return i=s.sent(),[4,U((l=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(r){rP(e,r,t[r])})}return e}({},function(e){var r,t,n,o,a=e.appDir,i=e.srcDir,c=e.entryPoint,s=e.workflowBlockModulesRef;return{entryPoints:[c],logLevel:"silent",bundle:!0,platform:"browser",format:"iife",sourcemap:("true"===(null!=(o=process.env.ATTIO_COVERAGE)?o:"").toLowerCase()||"1"===process.env.ATTIO_COVERAGE)&&"inline",plugins:[G({react:{varName:"React",type:"cjs",namedExports:["default","Children","Component","Fragment","Profiler","PureComponent","StrictMode","Suspense","SuspenseList","cloneElement","createContext","createElement","createFactory","createRef","forwardRef","isValidElement","lazy","memo","startTransition","unstable_SuspenseList","useCallback","useContext","useDebugValue","useDeferredValue","useEffect","useId","useImperativeHandle","useInsertionEffect","useLayoutEffect","useMemo","useReducer","useRef","useState","useSyncExternalStore","useTransition"]},attio:{varName:"ATTIO_ROOT_SDK",type:"cjs"},"attio/client":{varName:"ATTIO_CLIENT_EXTENSION_SDK",type:"cjs"}}),{name:rS,setup:function(e){e.onResolve({filter:/\.server$/},function(e){var r=u.relative(i,u.resolve(e.resolveDir,e.path));return{path:e.path,namespace:rS,pluginData:{moduleHash:r}}}),e.onLoad({filter:/.*/,namespace:rS},function(e){var r;return(r=function(){return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){var t;return[2,{contents:(t=e.pluginData.moduleHash,"\nexport default async function(...args) {\n return runServerFunction(".concat(JSON.stringify(t),", args)\n}")),loader:"js"}]})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(e){rk(a,n,o,i,c,"next",e)}function c(e){rk(a,n,o,i,c,"throw",e)}i(void 0)})})()})}},(t=(r={appDir:a,workflowBlockModulesRef:s}).appDir,n=r.workflowBlockModulesRef,{name:rO,setup:function(e){e.onResolve({filter:/\.block$/},function(e){var r=u.relative(t,u.resolve(e.resolveDir,e.path))+".ts";return{path:e.path,namespace:rO,pluginData:{modulePath:r}}}),e.onLoad({filter:/.*/,namespace:rO},function(e){var r;return(r=function(){return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){return[2,{contents:function(e,r){var t,n=0,o=new Map,a=!0,i=!1,c=void 0;try{for(var s,u=r.current.values()[Symbol.iterator]();!(a=(s=u.next()).done);a=!0){for(var l=s.value,f=l.execute,p=l.deferCallback,d=l.schema,h=l.activate,b=l.triggerCallback,y=l.deactivate,v=0,m=[f,p,h,b,y];v<m.length;v++){var w=m[v];w&&w.path===e&&("default"===w.export?o.set("default",'export default async function() {\n throw new Error("Exports from *.block.ts files cannot be called from the client.")\n}'):o.set(w.export,"export async function ".concat(w.export,'() {\n throw new Error("Exports from *.block.ts files cannot be called from the client.")\n}')))}if(d&&d.path===e)if("default"===d.export){var g=void 0;do g="schema_".concat(n++);while(!o.has(g));o.set("default","const ".concat(g,' = new Proxy({}, {\n get() {\n throw new Error("Exports from *.block.ts files cannot be called from the client.");\n }\n});\n\nexport default ').concat(g,";"))}else o.set(d.export,"export const ".concat(d.export,' = new Proxy({}, {\n get() {\n throw new Error("Exports from *.block.ts files cannot be called from the client.");\n }\n});'))}}catch(e){i=!0,c=e}finally{try{a||null==u.return||u.return()}finally{if(i)throw c}}return((function(e){if(Array.isArray(e))return r_(e)})(t=o.values())||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(t)||function(e,r){if(e){if("string"==typeof e)return r_(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return r_(e,void 0)}}(t)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).join("\n")}(e.pluginData.modulePath,n),loader:"js"}]})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(e){rE(a,n,o,i,c,"next",e)}function c(e){rE(a,n,o,i,c,"throw",e)}i(void 0)})})()})}})]}}({appDir:n.app,entryPoint:i.path,srcDir:n.src,workflowBlockModulesRef:a})),f=f={write:"write-to-disk"===o,outfile:r,loader:{".png":"dataurl",".graphql":"text",".gql":"text"}},Object.getOwnPropertyDescriptors?Object.defineProperties(l,Object.getOwnPropertyDescriptors(f)):(function(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(f)).forEach(function(e){Object.defineProperty(l,e,Object.getOwnPropertyDescriptor(f,e))}),l))];case 3:return[2,m(new t({esbuildContext:s.sent(),tempFile:i,workflowBlockModulesRef:a,directories:n}))];case 4:return c=s.sent(),[2,w({code:"FAILED_TO_CREATE_ESBUILD_CONTEXT",outfile:r,error:c})];case 5:return[2]}})}).apply(this,arguments)}}],e&&rj(t.prototype,e),r&&rj(t,r),t}();function rD(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function rF(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function rL(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){rF(a,n,o,i,c,"next",e)}function c(e){rF(a,n,o,i,c,"throw",e)}i(void 0)})}}function rU(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(t=o.next()).done)&&(a.push(t.value),!r||a.length!==r);i=!0);}catch(e){c=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw n}}return a}}(e,r)||rG(e,r)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function rM(e){return function(e){if(Array.isArray(e))return rD(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||rG(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function rG(e,r){if(e){if("string"==typeof e)return rD(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return rD(e,r)}}function rB(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function rV(e,r){return rL(function(){return rB(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,B("**/*.".concat(r,".{js,ts}"),{nodir:!0,cwd:e})];case 1:return[2,m.apply(void 0,[t.sent()])];case 2:return[2,w({code:"ERROR_FINDING_SERVER_FUNCTION_MODULES",path:e,pattern:r,cause:t.sent()})];case 3:return[2]}})})()}function rW(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function rJ(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){rW(a,n,o,i,c,"next",e)}function c(e){rW(a,n,o,i,c,"throw",e)}i(void 0)})}}function rY(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function rK(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function rH(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var rq=function(){"use strict";var e,r;function t(e){var r=e.esbuildContext,n=e.tempFile,o=e.directories;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");rK(this,"_lastJs",void 0),rK(this,"_esbuildContext",void 0),rK(this,"_tempFile",void 0),rK(this,"_directories",void 0),this._esbuildContext=r,this._tempFile=n,this._directories=o}return e=[{key:"rebuild",value:function(e){return rJ(function(e){var r,t,n,o,a,i,c,s;return rH(this,function(l){switch(l.label){case 0:return r=e.workflowBlockModules,[4,function(e){return rL(function(e){var r,t,n,o,a,i,c,s,l,f,p,d,h,b,y,w,_,k,S,T,x;return rB(this,function(A){switch(A.label){case 0:return r=e.appDirAbsolute,t=e.srcDirAbsolute,n=e.webhooksDirAbsolute,o=e.eventDirAbsolute,a=e.workflowBlockModules,i=e.log,[4,v({serverFunctionConcretePaths:rV(t,"server"),webhookConcretePaths:rV(n,"webhook"),eventConcretePaths:rV(o,"event")})];case 1:if(O(c=A.sent()))return[2,c];l=(s=c.value).serverFunctionConcretePaths,f=s.webhookConcretePaths,p=s.eventConcretePaths,d=l.map(function(e){return{path:e,hash:e.replace(/\.(js|ts)$/,"")}}),h=f.map(function(e){return{path:e,id:e.replace(/\.webhook\.(js|ts)$/,"")}}),b=p.map(function(e){return{path:e,id:e.replace(/\.event\.(js|ts)$/,"")}}),y=!0,w=!1,_=void 0;try{for(k=d[Symbol.iterator]();!(y=(S=k.next()).done);y=!0)T=S.value,null==i||i('\uD83D\uDD0E Found server module "'.concat(T.path,'"'))}catch(e){w=!0,_=e}finally{try{y||null==k.return||k.return()}finally{if(w)throw _}}return[4,g(I.readFile(u.join(t,e3)))];case 2:return x=E(A.sent())?"\n import appSettingsSchema from ".concat(JSON.stringify(u.join(t,e3)),"\n\n registerSettingsSchema(appSettingsSchema)\n "):"\n registerSettingsSchema({workspace: {}})\n ",[2,m("\n ".concat(x,"\n\n const modules = new Map()\n const webhookModules = new Map()\n const eventModules = new Map()\n const workflowModules = new Map()\n \n ").concat(d.map(function(e){return'modules.set("'.concat(e.hash,'", () => import(').concat(JSON.stringify(u.join(t,e.path)),"))")}).join("\n"),"\n\n ").concat(h.map(function(e){return'webhookModules.set("'.concat(e.id,'", () => import(').concat(JSON.stringify(u.join(n,e.path)),"))")}).join("\n"),"\n\n ").concat(b.map(function(e){return'eventModules.set("'.concat(e.id,'", () => import(').concat(JSON.stringify(u.join(o,e.path)),"))")}).join("\n"),"\n\n ").concat(rM(a.entries()).map(function(e){var t=rU(e,2),n=t[0],o=t[1];return"workflowModules.set(\n ".concat(JSON.stringify(n),",\n {\n ").concat(rM(Object.entries(o)).map(function(e){var t=rU(e,2),n=t[0],o=t[1];return o?"".concat(JSON.stringify(n),": {\n module: () => import(").concat(JSON.stringify(u.join(r,o.path)),"),\n export: ").concat(JSON.stringify(o.export),"\n },"):""}).join("\n"),"\n }\n )")}).join("\n"),'\n\n var stdin_default;\n var stdin_webhooks_default;\n var stdin_events_default;\n var stdin_workflow_block_handlers_default;\n\n function main() {\n stdin_default = async function(moduleHash, args) {\n const module = modules.get(moduleHash)\n\n if (!module) {\n throw new Error(`Module ${moduleHash} not found`)\n }\n\n const func = (await module()).default\n\n if (!func) {\n throw new Error(`Default export not found in module ${moduleHash}`)\n }\n\n if (typeof func !== "function") {\n throw new Error(`${moduleHash} does not export a function`)\n }\n\n return func(...args)\n }\n\n stdin_webhooks_default = async function(webhookModuleId, args) {\n const module = webhookModules.get(webhookModuleId)\n\n if (!module) {\n throw new Error(`Webhook handler not found: ${webhookModuleId}`)\n }\n\n const func = (await module()).default\n\n if (!func) {\n throw new Error(`Default export not found in module ${webhookModuleId}`)\n }\n\n if (typeof func !== "function") {\n throw new Error(`${webhookModuleId} does not export a function`)\n }\n\n return func(...args)\n }\n\n stdin_events_default = async function(eventModuleId, args) {\n const module = eventModules.get(eventModuleId)\n\n if (!module) {\n throw new Error("Event handler not found")\n }\n\n const func = (await module()).default\n\n if (!func) {\n throw new Error(`Default export not found in module ${eventModuleId}`)\n }\n\n if (typeof func !== "function") {\n throw new Error(`${eventModuleId} does not export a function`)\n }\n\n return func(...args)\n }\n\n stdin_workflow_block_handlers_default = async function(blockId, handler, args) {\n const modules = workflowModules.get(blockId)\n\n if (!modules) {\n throw new Error("Workflow block modules not found")\n }\n\n const handlerData = modules[handler]\n\n if (!handlerData) {\n throw new Error(`Workflow block module ${JSON.stringify(handler)} not found`)\n }\n\n if (handler === "schema") {\n const schema = (await handlerData.module())[handlerData.export]\n\n if (!schema) {\n throw new Error(`"${handler}" export not found in module ${JSON.stringify(blockId)}`)\n }\n\n return schema\n }\n\n const func = (await handlerData.module())[handlerData.export]\n\n if (!func) {\n throw new Error(`"${handler}" export not found in module ${JSON.stringify(blockId)}`)\n }\n\n if (typeof func !== "function") {\n throw new Error(`"${handler}" export in module ${JSON.stringify(blockId)} is not a function`)\n }\n\n return args ? func(...args) : func()\n }\n }\n\n main()\n\n'))]}})}).apply(this,arguments)}({appDirAbsolute:u.resolve(this._directories.app),srcDirAbsolute:u.resolve(this._directories.src),webhooksDirAbsolute:u.resolve(this._directories.webhooks),eventDirAbsolute:u.resolve(this._directories.events),workflowBlockModules:r})];case 1:if(O(t=l.sent()))return[2,t];if((n=t.value)===this._lastJs)return[3,5];l.label=2;case 2:return l.trys.push([2,4,,5]),[4,I.writeFile(this._tempFile.path,n)];case 3:return l.sent(),this._lastJs=n,[3,5];case 4:return o=l.sent(),[2,w({code:"FAILED_TO_CREATE_TEMP_FILE",path:this._tempFile.path,error:o})];case 5:return l.trys.push([5,7,,8]),[4,this._esbuildContext.rebuild()];case 6:return[2,m.apply(void 0,[l.sent()])];case 7:if(a=l.sent(),!(i=rx.safeParse(a)).success)return[2,w({code:"UNPARSABLE_BUILD_ERROR",error:a})];return[2,w({code:"BUILD_JAVASCRIPT_ERROR",errors:null!=(c=i.data.errors)?c:[],warnings:null!=(s=i.data.warnings)?s:[]})];case 8:return[2]}})}).apply(this,arguments)}},{key:"dispose",value:function(e){return rJ(function(){return rH(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,Promise.race([Promise.all([this._esbuildContext.dispose(),this._tempFile.cleanup()]),new Promise(function(r,t){return setTimeout(function(){return t(Error("Context disposal timeout"))},e)})])];case 1:return r.sent(),[3,3];case 2:return[2,w({code:"FAILED_TO_DISPOSE_OF_BUILD_CONTEXT",error:r.sent()})];case 3:return[2,m(void 0)]}})}).call(this)}}],r=[{key:"create",value:function(e){return rJ(function(e){var r,n,o,a,i;return rH(this,function(c){switch(c.label){case 0:r=e.outfile,n=e.directories,o=e.mode,c.label=1;case 1:return c.trys.push([1,4,,5]),[4,M.file({postfix:".js"})];case 2:var s,u;return[4,U((s=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(r){rK(e,r,t[r])})}return e}({},{entryPoints:[(a=c.sent()).path],bundle:!0,platform:"browser",format:"esm",plugins:[G({attio:{varName:"ATTIO_ROOT_SDK",type:"cjs"},"attio/server":{varName:"ATTIO_SERVER_APP_SDK",type:"cjs"}})]}),u=u={write:"write-to-disk"===o,outfile:r},Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(u)):(function(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(u)).forEach(function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(u,e))}),s))];case 3:return[2,m(new t({esbuildContext:c.sent(),tempFile:a,directories:n}))];case 4:return i=c.sent(),[2,w({code:"FAILED_TO_CREATE_ESBUILD_CONTEXT",outfile:r,error:i})];case 5:return[2]}})}).apply(this,arguments)}}],e&&rY(t.prototype,e),r&&rY(t,r),t}();function r$(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function rX(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){r$(a,n,o,i,c,"next",e)}function c(e){r$(a,n,o,i,c,"throw",e)}i(void 0)})}}function rz(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function rQ(e){return rX(function(){var r,t,n,o,a,i,c;return rz(this,function(s){switch(s.label){case 0:return r="src",t=u.join(r,"webhooks"),n=u.join(r,"events"),[4,v({client:rC.create({outfile:u.resolve("dist","index.js"),directories:{app:"",src:r},mode:e}),server:rq.create({outfile:u.resolve("dist","server.js"),directories:{app:"",src:r,webhooks:t,events:n},mode:e})})];case 1:if(O(o=s.sent()))return[2,o];return i=(a=o.value).client,c=a.server,[2,m({rebuild:function(){return rX(function(){var e,t;return rz(this,function(n){switch(n.label){case 0:var o,a;return[4,(o=r,(a=function(){var e,r,t,n;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(a){switch(a.label){case 0:return[4,eQ(o)];case 1:if(!(e=a.sent()))return[2,m(new Map)];return r=function(e){return C.readFileSync(e,"utf-8")},t=function(e){return C.existsSync(e)},n=new Map,[2,function(e,r,t){var n,o=new Map;try{var a=D(e,{range:!0,jsx:!0}),i=F(a,{sourceType:"module"}).acquire(a,!0);if(null===i)throw Error("Expected to be able to acquire module scope");L(a,null,{ExportNamedDeclaration:function(e,n){if(!e.declaration||"VariableDeclaration"!==e.declaration.type)throw Error("Expected export to be a variable declaration");if(1!==e.declaration.declarations.length)throw Error("Expected exactly one declaration per export");var a=e.declaration.declarations[0];if("Identifier"!==a.id.type||"app"!==a.id.name)throw Error("Expected export to be named 'app'");var c=a.init;if(!c||"ObjectExpression"!==c.type)throw Error("Expected app to be initialized to an object");var s=rg(c,"workflow",i);if((null==s?void 0:s.type)==="ObjectExpression"){var u=rg(s,"blocks",i);if((null==u?void 0:u.type)==="ObjectExpression"){var l=rg(u,"triggers",i);if((null==l?void 0:l.type)==="ArrayExpression"){var f=!0,p=!1,d=void 0;try{for(var h,b=l.elements[Symbol.iterator]();!(f=(h=b.next()).done);f=!0){var y=h.value;y&&rw(y,i,o,r,t)}}catch(e){p=!0,d=e}finally{try{f||null==b.return||b.return()}finally{if(p)throw d}}}var v=rg(u,"steps",i);if((null==v?void 0:v.type)==="ArrayExpression"){var m=!0,w=!1,g=void 0;try{for(var _,E=v.elements[Symbol.iterator]();!(m=(_=E.next()).done);m=!0){var O=_.value;O&&rw(O,i,o,r,t)}}catch(e){w=!0,g=e}finally{try{m||null==E.return||E.return()}finally{if(w)throw g}}}}}}})}catch(e){return w({code:"WORKFLOW_BLOCK_RESOLUTION_FAILED",message:(null!=(n=Error)&&"undefined"!=typeof Symbol&&n[Symbol.hasInstance]?!!n[Symbol.hasInstance](e):e instanceof n)?e.message:String(e)})}return m(o)}(e.content,e.path,{getModuleSource:r,doesModuleExist:t,modules:n})]}})},function(){var e=this,r=arguments;return new Promise(function(t,n){var o=a.apply(e,r);function i(e){rp(o,t,n,i,c,"next",e)}function c(e){rp(o,t,n,i,c,"throw",e)}i(void 0)})})())];case 1:if(O(e=n.sent()))return[2,e];return t=e.value,[2,v({client:i.rebuild({workflowBlockModules:t}),server:c.rebuild({workflowBlockModules:t})})]}})})()},dispose:function(e){return rX(function(){var r,t;return rz(this,function(n){switch(n.label){case 0:return[4,i.dispose(e)];case 1:return r=n.sent(),[4,c.dispose(e)];case 2:return t=n.sent(),[2,k(y([r,t]),function(){})]}})})()}})]}})})()}function rZ(e){switch(e.code){case"FAILED_TO_CREATE_TEMP_FILE":process.stderr.write("".concat(R.red("✖ "),"Failed to create temp file: ").concat(e.path,"\n"));break;case"FAILED_TO_GENERATE_CLIENT_ENTRY":process.stderr.write("".concat(R.red("✖ "),"Failed to generate client entry\n"));break;case"FAILED_TO_DISPOSE_OF_BUILD_CONTEXT":process.stderr.write("".concat(R.red("✖ "),"Failed to dispose of build context: ").concat(e.error,"\n"));break;case"FAILED_TO_CREATE_ESBUILD_CONTEXT":process.stderr.write("".concat(R.red("✖ "),"Failed to create esbuild context (").concat(e.outfile,"): ").concat(e.error,"\n"));break;case"ERROR_FINDING_SURFACE_EXPORTS":process.stderr.write("".concat(R.red("✖ "),"Failed to find surface exports: ").concat(e.error,"\n"));break;case"APP_ENTRY_POINT_NOT_FOUND":process.stderr.write("".concat(R.red("✖ "),"Could not find app.ts. See https://docs.attio.com/sdk/guides/app-ts-migration\n"));break;case"APP_EXPORT_NOT_FOUND":process.stderr.write("".concat(R.red("✖ "),'Could not find a named export "app" in ').concat(u.basename(e.path),". See https://docs.attio.com/sdk/guides/app-ts-migration\n"));break;case"UNPARSABLE_BUILD_ERROR":process.stderr.write("".concat(R.red("✖ "),"Failed to parse build error: ").concat(e.error,"\n"));break;case"ERROR_FINDING_SERVER_FUNCTION_MODULES":process.stderr.write("".concat(R.red("✖ "),"Failed to find server modules: ").concat(e.cause,"\n"));break;case"WORKFLOW_BLOCK_RESOLUTION_FAILED":process.stderr.write("".concat(R.red("✖ "),"Failed to build workflow block(s): ").concat(e.message,"\n"));break;default:return e}}function r0(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function r1(){var e;return(e=function(){var e,r,t,n;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(o){switch(o.label){case 0:return[4,rQ("write-to-disk")];case 1:if(O(e=o.sent()))return[2,e];return[4,(r=e.value).rebuild()];case 2:return t=o.sent(),[4,r.dispose(1e3)];case 3:if(O(n=o.sent()))return[2,n];if(O(t))return[2,t];return[2,m(!0)]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){r0(a,n,o,i,c,"next",e)}function c(e){r0(a,n,o,i,c,"throw",e)}i(void 0)})})()}function r2(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function r4(){var e;return(e=function(){var e,r,t;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,rs(u.resolve("tsconfig.json"))];case 1:if("Not a TypeScript project"===(e=n.sent()))return[2,m(!0)];return[4,ru(e)];case 2:if((r=n.sent()).length)return[2,w({code:"VALIDATE_TYPE_SCRIPT_ERROR",errors:r})];return[2,m(!0)];case 3:var o,a;if(o=t=n.sent(),null!=(a=Error)&&"undefined"!=typeof Symbol&&a[Symbol.hasInstance]?!!a[Symbol.hasInstance](o):o instanceof a)return[2,w({code:"VALIDATE_TYPE_SCRIPT_ERROR",errors:[rc.parse({text:t.message})]})];return[2,w({code:"FILE_SYSTEM_ERROR",error:t})];case 4:return[2]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){r2(a,n,o,i,c,"next",e)}function c(e){r2(a,n,o,i,c,"throw",e)}i(void 0)})})()}function r3(e,r,t){return(r3=r9()?Reflect.construct:function(e,r,t){var n=[null];n.push.apply(n,r);var o=new(Function.bind.apply(e,n));return t&&r7(o,t.prototype),o}).apply(null,arguments)}function r6(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function r5(e){return(r5=Object.setPrototypeOf?Object.getPrototypeOf:function(e){return e.__proto__||Object.getPrototypeOf(e)})(e)}function r7(e,r){return(r7=Object.setPrototypeOf||function(e,r){return e.__proto__=r,e})(e,r)}function r8(e){var r="function"==typeof Map?new Map:void 0;return(r8=function(e){if(null===e||-1===Function.toString.call(e).indexOf("[native code]"))return e;if("function"!=typeof e)throw TypeError("Super expression must either be null or a function");if(void 0!==r){if(r.has(e))return r.get(e);r.set(e,t)}function t(){return r3(e,arguments,r5(this).constructor)}return t.prototype=Object.create(e.prototype,{constructor:{value:t,enumerable:!1,writable:!0,configurable:!0}}),r7(t,e)})(e)}function r9(){try{var e=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch(e){}return(r9=function(){return!!e})()}var te=function(e){"use strict";var r;if("function"!=typeof e&&null!==e)throw TypeError("Super expression must either be null or a function");function t(e,r,n,o){var a,i,c;if(!(this instanceof t))throw TypeError("Cannot call a class as a function");return i=t,c=[e],i=r5(i),r6(a=function(e,r){var t;if(r&&("object"==((t=r)&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t)||"function"==typeof r))return r;if(void 0===e)throw ReferenceError("this hasn't been initialised - super() hasn't been called");return e}(this,r9()?Reflect.construct(i,c||[],r5(this).constructor):i.apply(this,c)),"locations",void 0),r6(a,"source",void 0),r6(a,"filename",void 0),a.locations=r,a.source=n,a.filename=o,a}return t.prototype=Object.create(e&&e.prototype,{constructor:{value:t,writable:!0,configurable:!0}}),e&&r7(t,e),r=[{key:"toString",value:function(){var e=this.locations[0],r=e.line,t=e.column;return"".concat(this.message,"\n\n").concat(this.filename,":").concat(this.locations[0].line,"\n\n").concat(X(this.source,{start:{line:r,column:t}}),"\n")}}],function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(t.prototype,r),t}(r8(Error));function tr(e,r){for(var t=1,n=1,o=0;o<r.start;o++)"\n"===e[o]?(t++,n=1):n++;return{line:t,column:n}}function tt(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function tn(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function to(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){tn(a,n,o,i,c,"next",e)}function c(e){tn(a,n,o,i,c,"throw",e)}i(void 0)})}}function ta(e){return function(e){if(Array.isArray(e))return tt(e)}(e)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(e)||ti(e)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ti(e,r){if(e){if("string"==typeof e)return tt(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return tt(e,r)}}function tc(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function ts(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function tu(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function tl(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function tf(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){tl(a,n,o,i,c,"next",e)}function c(e){tl(a,n,o,i,c,"throw",e)}i(void 0)})}}function tp(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):e instanceof r}function td(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function th(){return tf(function(){var e,r;return td(this,function(n){var o,a,i;switch(n.label){case 0:return n.trys.push([0,3,,4]),[4,(o=["schema.graphql"],(a=function(){var e,r,t;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:e=process.cwd(),n.label=1;case 1:if("/"===e)return[3,6];t=(r=u).join.apply(r,[e,"node_modules","attio"].concat(function(e){if(Array.isArray(e))return ts(e)}(o)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(o)||function(e,r){if(e){if("string"==typeof e)return ts(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return ts(e,void 0)}}(o)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())),n.label=2;case 2:return n.trys.push([2,4,,5]),[4,c.access(t)];case 3:return n.sent(),[2,t];case 4:return n.sent(),[3,5];case 5:return e=u.dirname(e),[3,1];case 6:return[2,null]}})},function(){var e=this,r=arguments;return new Promise(function(t,n){var o=a.apply(e,r);function i(e){tu(o,t,n,i,c,"next",e)}function c(e){tu(o,t,n,i,c,"throw",e)}i(void 0)})})())];case 1:return(e=n.sent())||e1("No schema.graphql found in node_modules. Did you run `npm install`?"),[4,(i=H(s(e,"utf8")),to(function(){return tc(this,function(e){switch(e.label){case 0:return[4,Promise.all((function e(r){var n=[],o=t.readdirSync(r,{withFileTypes:!0}),a=!0,i=!1,c=void 0;try{for(var s,l=o[Symbol.iterator]();!(a=(s=l.next()).done);a=!0){var f=s.value,p=u.join(r,f.name);f.isDirectory()?n.push.apply(n,ta(e(p))):f.isFile()&&".graphql.d.ts"===u.extname(f.name)&&n.push(p)}}catch(e){i=!0,c=e}finally{try{a||null==l.return||l.return()}finally{if(i)throw c}}return n})(".").map(function(e){return to(function(){return tc(this,function(r){return[2,t.promises.unlink(e)]})})()}))];case 1:return e.sent(),[4,Promise.all((function e(r){var n=[],o=t.readdirSync(r,{withFileTypes:!0}),a=!0,i=!1,c=void 0;try{for(var s,l=o[Symbol.iterator]();!(a=(s=l.next()).done);a=!0){var f=s.value,p=u.join(r,f.name);(!f.isDirectory()||"node_modules"!==f.name)&&(f.isDirectory()?n.push.apply(n,ta(e(p))):f.isFile()&&(".graphql"===u.extname(f.name)||".gql"===u.extname(f.name))&&n.push(p))}}catch(e){i=!0,c=e}finally{try{a||null==l.return||l.return()}finally{if(i)throw c}}return n})(".").map(function(e){return to(function(){var r,n,o;return tc(this,function(a){switch(a.label){case 0:return r=t.readFileSync(e,"utf-8"),[4,to(function(){var t,n,o,a,c,s,l,f,p,d,h,b,y,v,m,w,g,_,E,O;return tc(this,function(k){switch(k.label){case 0:o={};try{o=H(r)}catch(t){if(t.message.startsWith("Syntax Error: Unexpected Name"))throw new te(t.message,t.locations,r,e)}if(null==(t=o.definitions)||t.forEach(function(t){if(t&&t.kind===W.OPERATION_DEFINITION){var n=t.loc;if(!n)throw Error("Expected a location");switch(t.operation){case J.MUTATION:throw new te("Mutations are not supported",[tr(r,n)],r,e);case J.SUBSCRIPTION:throw new te("Subscriptions are not supported",[tr(r,n)],r,e);case J.QUERY:break;default:return t.operation}}}),(c=null!=(a=null==(n=o.definitions)?void 0:n.filter(function(e){return e&&e.kind===W.OPERATION_DEFINITION&&K(e)&&e.operation===J.QUERY}))?a:[]).length>1){if(!(l=null==(s=c[1])?void 0:s.loc))throw Error("Expected a location");throw new te("Only one query is allowed per .graphql file",[tr(r,l)],r,e)}if(!c.length)throw new te("No query found.",[{line:1,column:1}],r,e);switch((f=c[0]).kind){case W.OPERATION_DEFINITION:return[3,1];case W.FRAGMENT_DEFINITION:case W.SCHEMA_DEFINITION:case W.SCALAR_TYPE_DEFINITION:case W.OBJECT_TYPE_DEFINITION:case W.INTERFACE_TYPE_DEFINITION:case W.UNION_TYPE_DEFINITION:case W.ENUM_TYPE_DEFINITION:case W.INPUT_OBJECT_TYPE_DEFINITION:case W.DIRECTIVE_DEFINITION:case W.SCHEMA_EXTENSION:case W.SCALAR_TYPE_EXTENSION:case W.OBJECT_TYPE_EXTENSION:case W.INTERFACE_TYPE_EXTENSION:case W.UNION_TYPE_EXTENSION:case W.ENUM_TYPE_EXTENSION:case W.INPUT_OBJECT_TYPE_EXTENSION:return[3,6]}return[3,7];case 1:b=(h=null!=(d=K(f)&&f.kind===W.OPERATION_DEFINITION?null==(p=f.name)?void 0:p.value:void 0)?d:"")?h.charAt(0).toUpperCase()+h.slice(1):"Unnamed_1_",y="",k.label=2;case 2:return k.trys.push([2,4,,5]),[4,q({documents:[{document:o}],config:{},filename:"relative/pathTo/filename.ts",schema:i,plugins:[{"typescript-operations":{avoidOptionals:!0,enumsAsTypes:!0}}],pluginMap:{"typescript-operations":eb}})];case 3:return y=k.sent(),[3,5];case 4:if((v=k.sent()).message.startsWith("GraphQL Document Validation failed with")&&(m=v.message.match(/Error 0: (.+)\n\s+at GraphQL request:(\d+):(\d+)/))){var S;throw g=(w=function(e){if(Array.isArray(e))return e}(S=m)||function(e,r){var t,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(t=o.next()).done)&&(a.push(t.value),4!==a.length);i=!0);}catch(e){c=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw n}}return a}}(S,4)||ti(S,4)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[1],_=w[2],E=w[3],new te(g,[{line:parseInt(_),column:parseInt(E)}],r,e)}if(v.message.startsWith("Unable to find root schema type for"))throw new te(v.message,[{line:1,column:1}],r,e);throw v;case 5:return[2,$('\n declare module "./'.concat(u.basename(e),'" {\n ').concat(y.replace(/__typename\?: '[^']+',\s*/g,""),"\n const value: Query<").concat(b,"QueryVariables, ").concat(b,"Query>\n export default value\n}\n "),{parser:"typescript"})];case 6:if(!(O=f.loc))throw Error("Expected a location");throw new te("File should contain only a single query",[tr(r,O)],r,e);case 7:return[2,f];case 8:return[2]}})})()];case 1:return n=a.sent(),[4,$('/**\n * ****************************************************\n * THIS FILE IS AUTO-GENERATED AT DEVELOPMENT TIME.\n *\n * DO NOT EDIT DIRECTLY OR COMMIT IT TO SOURCE CONTROL.\n * ****************************************************\n */\nimport {Query} from "attio/client"\n\ntype Exact<T extends { [key: string]: unknown }> = { [K in keyof T]: T[K] };\n\ntype Scalars = {\n ID: { input: string; output: string };\n String: { input: string; output: string };\n Boolean: { input: boolean; output: boolean };\n Int: { input: number; output: number };\n Float: { input: number; output: number };\n};\n\n'.concat(n,"\n"),{parser:"typescript"})];case 2:return o=a.sent(),[4,t.promises.writeFile("".concat(e,".d.ts"),o)];case 3:return a.sent(),[2]}})})()}))];case 2:return e.sent(),[2]}})})())];case 2:return n.sent(),[2,m(!0)];case 3:if(tp(r=n.sent(),te))return[2,w({code:"GRAPHQL_ERROR",error:r})];return[2,w({code:"GRAPHQL_CODEGEN_ERROR",error:tp(r,Error)?r.message:"GraphQL code generation failed"})];case 4:return[2]}})})()}function tb(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var ty=new d("build").description("Build your Attio extension locally").action(function(){var e;return(e=function(){var e,r,t,n,o,a;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:return[4,e0()];case 1:return O(i.sent())&&e2(),[4,rr("Generating GraphQL types...","GraphQL types generated successfully",th)];case 2:return O(e=i.sent())&&e1(e.error.error.toString()),[4,e5()];case 3:return O(i.sent())&&e1("Failed to generate settings types"),[4,rr("Validating TypeScript...","TypeScript validation passed",r4)];case 4:if(O(r=i.sent()))switch(r.error.code){case"VALIDATE_TYPE_SCRIPT_ERROR":r.error.errors.forEach(rl),process.stderr.write("TypeScript validation failed"),process.exit(1);case"FILE_SYSTEM_ERROR":process.stderr.write("TypeScript validation failed due to a file system error: ".concat(r.error.error)),process.exit(1)}return[4,rr("Building JavaScript...","JavaScript build completed successfully",r1)];case 5:return O(t=i.sent())&&("BUILD_JAVASCRIPT_ERROR"===t.error.code?(o=(n=t.error).errors,a=n.warnings,null==o||o.forEach(function(e){return rf(e,"error")}),null==a||a.forEach(function(e){return rf(e,"warning")}),process.stderr.write("JavaScript build failed")):(rZ(t.error),process.stderr.write("Build context error")),process.exit(1)),[2]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){tb(a,n,o,i,c,"next",e)}function c(e){tb(a,n,o,i,c,"throw",e)}i(void 0)})})()}),tv="development"===process.env.NODE_ENV,tm="attio.".concat(tv?"me":"com"),tw="https://build.".concat(tm,"/api"),tg="https://".concat("app.".concat(tm)),t_="2026-02-23";function tE(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function tO(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){tE(a,n,o,i,c,"next",e)}function c(e){tE(a,n,o,i,c,"throw",e)}i(void 0)})}}function tk(e,r){return null!=r&&"undefined"!=typeof Symbol&&r[Symbol.hasInstance]?!!r[Symbol.hasInstance](e):e instanceof r}function tS(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(r){var n;n=t[r],r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n})}return e}function tI(e,r){return r=null!=r?r:{},Object.getOwnPropertyDescriptors?Object.defineProperties(e,Object.getOwnPropertyDescriptors(r)):(function(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(r)).forEach(function(t){Object.defineProperty(e,t,Object.getOwnPropertyDescriptor(r,t))}),e}function tT(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var tx=b.object({message:b.string()}),tA=function(){"use strict";var e;function r(){if(!(this instanceof r))throw TypeError("Cannot call a class as a function")}return e=[{key:"_fetch",value:function(e){return tO(function(e){var r,t,n,o,a,i,c,s,u,l,f,p,d;return tT(this,function(h){switch(h.label){case 0:if(r=e.path,t=e.fetchOptions,n=e.schema,"Authenticated"!==e.authenticated)return[3,2];return[4,np.ensureAuthed()];case 1:return a=h.sent(),[3,3];case 2:a=m(null),h.label=3;case 3:if(O(o=a))return[2,w({code:"UNAUTHORIZED",error:o.error})];i=o.value,h.label=4;case 4:return h.trys.push([4,9,,10]),[4,fetch(r.startsWith("https")?r:"".concat(tw).concat(r),tI(tS({},t),{headers:tS(tI(tS({"x-attio-platform":"developer-cli"},i?{Authorization:"Bearer ".concat(i)}:{}),{"Content-Type":"application/json"}),t.headers)}))];case 5:if((c=h.sent()).ok)return[3,7];return l=(u=this)._parseErrorResponseMessage,[4,c.text()];case 6:return s=l.apply(u,[h.sent()]),[2,w({code:"HTTP_ERROR",status:c.status,message:s})];case 7:return[4,c.json()];case 8:if(f=h.sent(),!(p=n.safeParse(f)).success)return[2,w({code:"INVALID_RESPONSE",message:p.error.message})];return[2,m(p.data)];case 9:return[2,w({code:"NETWORK_ERROR",message:tk(d=h.sent(),Error)?d.message:String(d)})];case 10:return[2]}})}).apply(this,arguments)}},{key:"_parseErrorResponseMessage",value:function(e){try{return tx.parse(JSON.parse(e)).message}catch(r){return e}}},{key:"get",value:function(e){return tO(function(e){var r,t,n,o,a,i;return tT(this,function(c){return r=e.path,t=e.schema,o=void 0===(n=e.headers)?{}:n,i=void 0===(a=e.authenticated)?"Authenticated":a,[2,this._fetch({path:r,fetchOptions:{method:"GET",headers:o},schema:t,authenticated:i})]})}).apply(this,arguments)}},{key:"post",value:function(e){return tO(function(e){var r,t,n,o,a,i,c;return tT(this,function(s){return r=e.path,t=e.body,n=e.schema,a=void 0===(o=e.headers)?{}:o,c=void 0===(i=e.authenticated)?"Authenticated":i,[2,this._fetch({path:r,fetchOptions:{method:"POST",body:tk(t,URLSearchParams)?t.toString():JSON.stringify(t),headers:tS({"Content-Type":tk(t,URLSearchParams)?"application/x-www-form-urlencoded":"application/json"},a)},schema:n,authenticated:c})]})}).apply(this,arguments)}}],function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,e),r}(),tR=b.object({user:b.object({id:b.string(),email_address:b.string(),name:b.object({full:b.string()})})}),tj=b.object({workspace_id:b.string().uuid(),slug:b.string(),name:b.string(),logo_url:b.string().nullable()}),tP=[tj.parse({workspace_id:"a85e3bcf-a9a2-4df9-9e92-e708bf98d238",slug:"test-slug",name:"Test Workspace",logo_url:null})],tN=b.object({workspaces:b.array(tj)}),tC=b.object({app_id:b.string().uuid(),major:b.number(),minor:b.number(),app_prod_version_bundle_id:b.string(),client_bundle_upload_url:b.string(),server_bundle_upload_url:b.string()}),tD=b.object({app:b.object({app_id:b.string().uuid(),title:b.string()})}),tF=tD.parse({app:{app_id:"0cbafb09-2ef7-473c-a048-08a5d190a395",title:"Test App"}}),tL=b.object({success:b.literal(!0)}),tU=b.object({app_dev_version_id:b.string().uuid(),app_dev_version_bundle_id:b.string().uuid(),client_bundle_upload_url:b.string().url(),server_bundle_upload_url:b.string().url()}),tM=b.object({app_id:b.string().uuid(),app_dev_version_id:b.string()}),tG=b.object({app_id:b.string().uuid(),workspace_id:b.string()}),tB=b.object({major:b.number(),minor:b.number(),created_at:b.string(),released_at:b.string().nullable().optional(),is_published:b.boolean(),num_installations:b.number(),publication_status:b.enum(["private","in-review","published","rejected"])}),tV=b.object({app_prod_versions:b.array(tB)}),tW=b.object({access_token:b.string(),token_type:b.literal("Bearer"),refresh_token:b.string(),expires_in:b.number()}),tJ=b.object({capability:b.string(),clientId:b.string().optional(),expires:b.number(),issued:b.number(),token:b.string()});function tY(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function tK(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){tY(a,n,o,i,c,"next",e)}function c(e){tY(a,n,o,i,c,"throw",e)}i(void 0)})}}function tH(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var tq=new(function(){"use strict";var e;function r(){var e,t;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");t=void 0,(e="_fetcher")in this?Object.defineProperty(this,e,{value:t,enumerable:!0,configurable:!0,writable:!0}):this[e]=t,this._fetcher=new tA}return e=[{key:"whoami",value:function(){return tK(function(){var e;return tH(this,function(r){switch(r.label){case 0:return[4,this._fetcher.get({path:"".concat(tg,"/api/auth/whoami"),schema:tR})];case 1:if(O(e=r.sent()))return[2,w({code:"WHOAMI_ERROR",error:e.error})];return[2,m(e.value.user)]}})}).call(this)}},{key:"fetchWorkspaces",value:function(){return tK(function(){var e;return tH(this,function(r){switch(r.label){case 0:if("test"===process.env.NODE_ENV)return[2,m(tP)];return[4,this._fetcher.get({path:"/dev-workspaces",schema:tN})];case 1:if(O(e=r.sent()))return[2,w({code:"FETCH_WORKSPACES_ERROR",error:e.error})];return[2,m(e.value.workspaces)]}})}).call(this)}},{key:"createVersion",value:function(e){return tK(function(e){var r,t,n,o;return tH(this,function(a){switch(a.label){case 0:return r=e.appId,t=e.major,n=e.cliVersion,[4,this._fetcher.post({path:"/apps/".concat(r,"/prod-versions"),body:{major:t,cli_version:n,sdk_version:t_},schema:tC})];case 1:if(O(o=a.sent()))return[2,w({code:"CREATE_VERSION_ERROR",error:o.error})];return[2,o]}})}).apply(this,arguments)}},{key:"fetchAppInfo",value:function(e){return tK(function(){var r;return tH(this,function(t){switch(t.label){case 0:if("test"===process.env.NODE_ENV)return[2,m(tF.app)];return[4,this._fetcher.get({path:"/apps/by-slug/".concat(e),schema:tD})];case 1:if(O(r=t.sent())){if("HTTP_ERROR"===r.error.code&&404===r.error.status)return[2,w({code:"APP_NOT_FOUND"})];return[2,w({code:"FETCH_APP_INFO_ERROR",error:r.error})]}return[2,m(r.value.app)]}})}).call(this)}},{key:"completeBundleUpload",value:function(e){return tK(function(e){var r,t,n,o;return tH(this,function(a){switch(a.label){case 0:return r=e.appId,t=e.devVersionId,n=e.bundleId,[4,this._fetcher.post({path:"/apps/".concat(r,"/dev-versions/").concat(t,"/bundles/").concat(n,"/complete"),body:{},schema:tL})];case 1:if(O(o=a.sent()))return[2,w({code:"COMPLETE_BUNDLE_UPLOAD_ERROR",error:o.error})];return[2,m(void 0)]}})}).apply(this,arguments)}},{key:"completeProdBundleUpload",value:function(e){return tK(function(e){var r,t,n,o,a;return tH(this,function(i){switch(i.label){case 0:return r=e.appId,t=e.bundleId,n=e.major,o=e.minor,[4,this._fetcher.post({path:"/apps/".concat(r,"/prod-versions/").concat(n,"/").concat(o,"/bundles/").concat(t,"/complete"),body:{},schema:tL})];case 1:if(O(a=i.sent()))return[2,w({code:"COMPLETE_PROD_BUNDLE_UPLOAD_ERROR",error:a.error})];return[2,m(void 0)]}})}).apply(this,arguments)}},{key:"startUpload",value:function(e){return tK(function(e){var r,t,n;return tH(this,function(o){switch(o.label){case 0:return r=e.appId,t=e.devVersionId,[4,this._fetcher.post({path:"/apps/".concat(r,"/dev-versions/").concat(t,"/bundles"),body:{sdk_version:t_},schema:tU})];case 1:if(O(n=o.sent()))return[2,w({code:"START_UPLOAD_ERROR",error:n.error})];return[2,n]}})}).apply(this,arguments)}},{key:"createDevVersion",value:function(e){return tK(function(e){var r,t,n,o,a;return tH(this,function(i){switch(i.label){case 0:return r=e.appId,t=e.cliVersion,n=e.targetWorkspaceId,o=e.environmentVariables,[4,this._fetcher.post({path:"/apps/".concat(r,"/dev-versions"),body:{major:1,target_workspace_id:n,environment_variables:o,cli_version:t},schema:tM})];case 1:if(O(a=i.sent()))return[2,w({code:"CREATE_DEV_VERSION_ERROR",error:a.error})];return[2,a]}})}).apply(this,arguments)}},{key:"fetchInstallation",value:function(e){return tK(function(e){var r,t,n;return tH(this,function(o){switch(o.label){case 0:return r=e.appId,t=e.workspaceId,[4,this._fetcher.get({path:"/apps/".concat(r,"/workspace/").concat(t,"/dev-installation"),schema:tG})];case 1:if(O(n=o.sent())){if("HTTP_ERROR"===n.error.code&&404===n.error.status)return[2,m(null)];return[2,w({code:"FETCH_INSTALLATION_ERROR",error:n.error})]}return[2,n]}})}).apply(this,arguments)}},{key:"fetchVersions",value:function(e){return tK(function(){var r;return tH(this,function(t){switch(t.label){case 0:return[4,this._fetcher.get({path:"/apps/".concat(e,"/prod-versions"),schema:tV})];case 1:if(O(r=t.sent()))return[2,w({code:"FETCH_VERSIONS_ERROR",error:r.error})];return[2,m(r.value.app_prod_versions)]}})}).call(this)}},{key:"exchangeToken",value:function(e){return tK(function(e){var r,t,n,o,a,i;return tH(this,function(c){switch(c.label){case 0:return r=e.receivedCode,t=e.verifierString,n=e.redirectUri,o=e.clientId,(a=new URLSearchParams).append("grant_type","authorization_code"),a.append("code",r),a.append("client_id",o),a.append("redirect_uri",n),a.append("code_verifier",t),[4,this._fetcher.post({path:"".concat(tg,"/oidc/token"),body:a,schema:tW,authenticated:"Not Authenticated"})];case 1:if(O(i=c.sent()))return[2,w({code:"GET_TOKEN_ERROR",error:i.error})];return[2,i]}})}).apply(this,arguments)}},{key:"refreshToken",value:function(e){return tK(function(e){var r,t,n,o;return tH(this,function(a){switch(a.label){case 0:return r=e.refreshToken,t=e.clientId,(n=new URLSearchParams).append("grant_type","refresh_token"),n.append("refresh_token",r),n.append("client_id",t),[4,this._fetcher.post({path:"".concat(tg,"/oidc/token"),body:n,schema:tW})];case 1:if(O(o=a.sent()))return[2,w({code:"REFRESH_TOKEN_ERROR",error:o.error})];return[2,o]}})}).apply(this,arguments)}},{key:"authenticateAbly",value:function(e){return tK(function(){var r;return tH(this,function(t){switch(t.label){case 0:return[4,this._fetcher.post({path:"/integrations/ably/auth",body:{token_params:e},schema:tJ})];case 1:if(O(r=t.sent()))return[2,w({code:"ABLY_AUTHENTICATION_ERROR",message:"message"in r.error?r.error.message:r.error.code})];return[2,r]}})}).call(this)}}],function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,e),r}());function t$(e,r){var t=r.error;switch(process.stderr.write("".concat(R.red("✖ ")).concat(e,"\n")),t.code){case"HTTP_ERROR":process.stderr.write("HTTP Error (".concat(t.status,"): ").concat(t.message,"\n"));break;case"INVALID_RESPONSE":process.stderr.write("Invalid response: ".concat(t.message,"\n"));break;case"NETWORK_ERROR":process.stderr.write("Network error: ".concat(t.message,"\n"));break;case"UNAUTHORIZED":process.stderr.write('Unauthorized. You must log in with "attio login"\n')}}function tX(e){switch(e.code){case"APP_NOT_FOUND":var r="development"===process.env.NODE_ENV?"https://build.attio.me":"https://build.attio.com";process.stderr.write("\n".concat(R.red("✖ "),"App not found. Did you create it in the developer portal at ").concat(r,"?\n"));break;case"FETCH_APP_INFO_ERROR":t$("Error loading app info",{error:e.error});break;default:return e}}function tz(e){var r=e.code,t=e.error;switch(r){case"MALFORMED_PACKAGE_JSON":t.issues.length>0?process.stderr.write("".concat(R.red("✖ "),"Malformed package.json: ").concat(t.issues[0].message,"\n")):process.stderr.write("".concat(R.red("✖ "),"Malformed package.json: ").concat(t.message,"\n"));break;case"FILE_SYSTEM_ERROR":process.stderr.write("".concat(R.red("✖ "),"Failed to read package.json\n"));break;case"INVALID_JSON":process.stderr.write("".concat(R.red("✖ "),"Invalid JSON in package.json: ").concat(t,"\n"))}}function tQ(e){var r=e.error;switch(r.code){case"UNABLE_TO_FIND_PACKAGE_JSON":process.stderr.write("".concat(R.red("✖ "),"Failed to find package.json in ").concat(r.path,"\n"));break;case"UNABLE_TO_READ_PACKAGE_JSON":process.stderr.write("".concat(R.red("✖ "),"Failed to read package.json: ").concat(r.error,"\n"));break;case"UNABLE_TO_PARSE_PACKAGE_JSON":process.stderr.write("".concat(R.red("✖ "),"Failed to parse package.json: ").concat(r.error,"\n"));break;case"INVALID_PACKAGE_JSON":process.stderr.write("".concat(R.red("✖ "),"Invalid package.json: ").concat(r.error,"\n"));break;case"ERROR_LOADING_PACKAGE_JSON":process.stderr.write("".concat(R.red("✖ "),"Error loading package.json: ").concat(r.error,"\n"));break;case"NO_CLI_VERSION_FOUND":process.stderr.write("".concat(R.red("✖ "),"No CLI version found in attio's package.json\n"));break;default:return r}}function tZ(e){switch(e.code){case"FETCH_WORKSPACES_ERROR":process.stderr.write("Error fetching workspaces: ".concat(e.error,"\n\n").concat(tg,"/welcome/workspace-details\n "));break;case"NO_WORKSPACE_FOUND":process.stderr.write('You are not the admin any workspace with the slug "'.concat(e.workspace_slug,'". Either request permission from "').concat(e.workspace_slug,'" or create your own.\n\n').concat(tg,"/welcome/workspace-details\n "));break;case"NO_WORKSPACES_FOUND":process.stderr.write("You are not the admin of any workspaces. Either request permission from an existing workspace or create your own.\n\n".concat(tg,"/welcome/workspace-details\n "));break;default:return e}}function t0(e){switch(e.code){case"SAVE_KEYCHAIN_ERROR":process.stderr.write(R.red("Error saving token to keychain: ".concat(e.error)));break;case"LOAD_KEYCHAIN_ERROR":process.stderr.write(R.red("Error loading token from keychain: ".concat(e.error)));break;case"DELETE_KEYCHAIN_ERROR":process.stderr.write(R.red("Error deleting token from keychain: ".concat(e.error)));break;default:return e}}function t1(e){if("FAILED_TO_CONNECT_TO_LOGS_SERVER"!==e.code)return e.code;var r,t,n="Failed to connect to logs server";r=e.error,(null!=(t=Error)&&"undefined"!=typeof Symbol&&t[Symbol.hasInstance]?!!t[Symbol.hasInstance](r):r instanceof t)&&(n="".concat(n,": ").concat(e.error.message)),process.stderr.write(R.red("\n".concat(n,"\n")))}function t2(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function t4(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){t2(a,n,o,i,c,"next",e)}function c(e){t2(a,n,o,i,c,"throw",e)}i(void 0)})}}function t3(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function t6(e){var r=arguments.length>1&&void 0!==arguments[1]?arguments[1]:100;return t4(function(){var t;return t3(this,function(n){switch(n.label){case 0:t=e,n.label=1;case 1:var o;if(!(t<e+r))return[3,4];return[4,(o=t,t4(function(){return t3(this,function(e){return[2,new Promise(function(e){var r=en.createConnection(o,"127.0.0.1");r.setTimeout(1e3);var t=function(){r.removeAllListeners(),r.destroy()};r.once("error",function(r){t(),"ECONNREFUSED"===r.code?e(!0):e(!1)}),r.once("connect",function(){t(),e(!1)}),r.once("timeout",function(){t(),e(!1)})})]})})())];case 2:if(n.sent())return[2,t];n.label=3;case 3:return t++,[3,1];case 4:return e1("Could not find an available port after ".concat(r," attempts")),[2]}})})()}function t5(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function t7(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){t5(a,n,o,i,c,"next",e)}function c(e){t5(a,n,o,i,c,"throw",e)}i(void 0)})}}function t8(e,r){if(!(e instanceof r))throw TypeError("Cannot call a class as a function")}function t9(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}function ne(e,r,t){return r&&t9(e.prototype,r),t&&t9(e,t),e}function nr(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function nt(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var nn=b.object({access_token:b.string(),refresh_token:b.string(),token_type:b.literal("Bearer"),expires_at:b.number()}),no=function(){"use strict";function e(){t8(this,e),nr(this,"SERVICE_NAME","attio-cli"),nr(this,"ACCOUNT_NAME","developer"),nr(this,"keytarPromise",void 0),this.keytarPromise=e_.e("137").then(e_.bind(e_,360)).then(function(e){return e.default})}return ne(e,[{key:"save",value:function(e){return t7(function(){var r;return nt(this,function(t){switch(t.label){case 0:return[4,this.keytarPromise];case 1:r=t.sent(),t.label=2;case 2:return t.trys.push([2,4,,5]),[4,r.setPassword(this.SERVICE_NAME,this.ACCOUNT_NAME,JSON.stringify(e))];case 3:return t.sent(),[2,m(void 0)];case 4:return[2,w({code:"SAVE_KEYCHAIN_ERROR",error:t.sent()})];case 5:return[2]}})}).call(this)}},{key:"load",value:function(){return t7(function(){var e,r,t,n,o,a,i;return nt(this,function(c){switch(c.label){case 0:return[4,this.keytarPromise];case 1:e=c.sent(),r=null,c.label=2;case 2:return c.trys.push([2,4,,5]),[4,e.getPassword(this.SERVICE_NAME,this.ACCOUNT_NAME)];case 3:return r=c.sent(),[3,5];case 4:return[2,w({code:"LOAD_KEYCHAIN_ERROR",error:c.sent()})];case 5:if(null===r)return[2,m(null)];c.label=6;case 6:return c.trys.push([6,7,,9]),t=JSON.parse(r),[3,9];case 7:return c.sent(),[4,this.delete()];case 8:if(O(n=c.sent()))return[2,w({code:"LOAD_KEYCHAIN_ERROR",error:n.error})];return console.debug("Wiped keychain entry due to invalid JSON"),[2,m(null)];case 9:if((o=nn.safeParse(t)).success)return[3,11];return[4,this.delete()];case 10:if(O(a=c.sent()))return[2,w({code:"LOAD_KEYCHAIN_ERROR",error:a.error})];return console.debug("Wiped keychain entry due to schema mismatch"),[2,m(null)];case 11:if(!(o.data.expires_at<Date.now()+3e5))return[3,13];return[4,this.delete()];case 12:if(O(i=c.sent()))return[2,w({code:"LOAD_KEYCHAIN_ERROR",error:i.error})];return[2,m(null)];case 13:return[2,m(o.data)]}})}).call(this)}},{key:"delete",value:function(){return t7(function(){var e;return nt(this,function(r){switch(r.label){case 0:return[4,this.keytarPromise];case 1:e=r.sent(),r.label=2;case 2:return r.trys.push([2,4,,5]),[4,e.deletePassword(this.SERVICE_NAME,this.ACCOUNT_NAME)];case 3:return r.sent(),[2,m(void 0)];case 4:return[2,w({code:"DELETE_KEYCHAIN_ERROR",error:r.sent()})];case 5:return[2]}})}).call(this)}}]),e}(),na=function(){"use strict";function e(){t8(this,e),nr(this,"TEST_TOKEN",{access_token:"TEST",refresh_token:"TEST",token_type:"Bearer",expires_at:Number.MAX_SAFE_INTEGER})}return ne(e,[{key:"save",value:function(e){return t7(function(){return nt(this,function(e){return[2,m(void 0)]})})()}},{key:"load",value:function(){return t7(function(){return nt(this,function(e){return[2,m(this.TEST_TOKEN)]})}).call(this)}},{key:"delete",value:function(){return t7(function(){return nt(this,function(e){return[2,m(void 0)]})})()}}]),e}(),ni=null,nc=function(){return null===ni&&(ni="test"===process.env.NODE_ENV?new na:new no),ni};function ns(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nu(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){ns(a,n,o,i,c,"next",e)}function c(e){ns(a,n,o,i,c,"throw",e)}i(void 0)})}}function nl(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function nf(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var np=new(function(){"use strict";var e;function r(){if(!(this instanceof r))throw TypeError("Cannot call a class as a function");nl(this,"clientId","f881c6f1-82d7-48a5-a581-649596167845"),nl(this,"isRefreshingToken",!1),nl(this,"refreshTimeout",null)}return e=[{key:"ensureAuthed",value:function(){return nu(function(){var e,r;return nf(this,function(t){switch(t.label){case 0:return[4,nc().load()];case 1:if(O(e=t.sent())||null===(r=e.value)||r.expires_at<Date.now())return[2,this.promptToAuthenticate()];return this.scheduleRefresh(r),[2,m(r.access_token)]}})}).call(this)}},{key:"promptToAuthenticate",value:function(){return nu(function(){return nf(this,function(e){switch(e.label){case 0:if("test"===process.env.NODE_ENV)return[3,2];return process.stdout.write("You need to log in with Attio. Press Enter to continue...\n\n"),[4,new Promise(function(e){return process.stdin.once("data",e)})];case 1:e.sent(),e.label=2;case 2:return[2,this.authenticate()]}})}).call(this)}},{key:"authenticate",value:function(){return nu(function(){var e,r,t,n,o,a,i,c,s,u,l,f,p,d,h,b,y;return nf(this,function(v){switch(v.label){case 0:return e=this,[4,nc().load()];case 1:if(O(r=v.sent()))return[2,r];if(null!==(t=r.value)&&t.expires_at>Date.now())return[2,m(t.access_token)];return n=Z(32).toString("base64url"),o=Q("sha256").update(n,"utf8").digest().toString("base64url"),a=Z(32).toString("base64url"),[4,t6(3e3,65e3)];case 2:i=v.sent(),c="http://localhost:".concat(i),u=new Promise(function(e){s=e}),(l=new er).get("/",function(r){return nu(function(){var e,t,o;return nf(this,function(i){switch(i.label){case 0:return t=(e=r.req.query()).code,e.state!==a&&s(w({code:"OAUTH_STATE_MISMATCH"})),t||s(w({code:"NO_AUTHORIZATION_CODE"})),[4,tq.exchangeToken({receivedCode:t,verifierString:n,redirectUri:c,clientId:this.clientId})];case 1:return o=i.sent(),setTimeout(function(){f.close(),s(o)},1e3),[2,r.html("\n <html>\n <body>\n <script>window.location.href = '".concat(tg,"/authorized';<\/script>\n </body>\n </html>\n "))]}})}).call(e)}),f=ee({fetch:l.fetch,port:i}),v.label=3;case 3:return v.trys.push([3,,7,8]),(p=new URL("".concat(tg,"/oidc/authorize"))).searchParams.append("scope","openid offline_access"),p.searchParams.append("response_type","code"),p.searchParams.append("client_id",this.clientId),p.searchParams.append("redirect_uri",c),p.searchParams.append("state",a),p.searchParams.append("code_challenge",o),p.searchParams.append("code_challenge_method","S256"),[4,et(p.toString())];case 4:return v.sent(),[4,u];case 5:if(O(d=v.sent()))return[2,d];return h=d.value,process.stdout.write("\uD83D\uDD11 Saving new token to keychain\n"),b={access_token:h.access_token,refresh_token:h.refresh_token,token_type:h.token_type,expires_at:Date.now()+1e3*h.expires_in},[4,nc().save(b)];case 6:if(O(y=v.sent()))return[2,y];return this.scheduleRefresh(b),[2,m(h.access_token)];case 7:return f.close(),[7];case 8:return[2]}})}).call(this)}},{key:"scheduleRefresh",value:function(e){var r=this;null!==this.refreshTimeout&&clearTimeout(this.refreshTimeout);var t=Math.min(Math.max(0,(e.expires_at-Date.now())/10),0x7fffffff);this.refreshTimeout=setTimeout(function(){return nu(function(){return nf(this,function(r){switch(r.label){case 0:if(this.isRefreshingToken)return[2];this.isRefreshingToken=!0,r.label=1;case 1:return r.trys.push([1,,3,4]),[4,this.refreshToken(e)];case 2:return r.sent(),[3,4];case 3:return this.isRefreshingToken=!1,this.refreshTimeout=null,[7];case 4:return[2]}})}).call(r)},t)}},{key:"refreshToken",value:function(e){return nu(function(){var r,t,n,o;return nf(this,function(a){switch(a.label){case 0:return[4,tq.refreshToken({refreshToken:e.refresh_token,clientId:this.clientId})];case 1:if(O(r=a.sent()))return t$("Error refreshing token",r.error),[2];return n={access_token:(t=r.value).access_token,refresh_token:t.refresh_token,token_type:t.token_type,expires_at:Date.now()+1e3*t.expires_in},[4,nc().save(n)];case 2:if(O(o=a.sent()))return t0(o.error),[2];return this.scheduleRefresh(n),[2]}})}).call(this)}},{key:"logout",value:function(){return nu(function(){return nf(this,function(e){switch(e.label){case 0:return null!==this.refreshTimeout&&(clearTimeout(this.refreshTimeout),this.refreshTimeout=null),[4,nc().delete()];case 1:return e.sent(),[2]}})}).call(this)}}],function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,e),r}());function nd(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function nh(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var nb=b.object({include:b.array(b.string())}).passthrough();function ny(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var nv=".gitignore",nm="node_modules\ngraphql.d.ts\n".concat(e4,"\n.DS_Store\n");function nw(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function ng(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){nw(a,n,o,i,c,"next",e)}function c(e){nw(a,n,o,i,c,"throw",e)}i(void 0)})}}function n_(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function nE(e){return ng(function(){var r,t,n,o;return n_(this,function(a){switch(a.label){case 0:return[4,rr("Loading workspaces...","Workspaces loaded",function(){return ng(function(){return n_(this,function(e){switch(e.label){case 0:return[4,tq.fetchWorkspaces()];case 1:return[2,e.sent()]}})})()})];case 1:if(O(r=a.sent()))return[2,r];if(n=(t=r.value).find(function(r){return r.slug===e}))return process.stdout.write("Using workspace: ".concat(n.name)),[2,m(n)];if(e)return[2,w({code:"NO_WORKSPACE_FOUND",workspace_slug:e})];if(0===t.length)return[2,w({code:"NO_WORKSPACES_FOUND"})];if(1===t.length)return process.stdout.write("Using workspace: ".concat(t[0].name)),[2,m(t[0])];return[4,ei({message:"Choose a workspace",choices:t.map(function(e){return{name:e.name,value:e}})})];case 2:return o=a.sent(),process.stdout.write("Using workspace: ".concat(o.name)),[2,m(o)]}})})()}function nO(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nk(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){nO(a,n,o,i,c,"next",e)}function c(e){nO(a,n,o,i,c,"throw",e)}i(void 0)})}}function nS(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function nI(e){return nk(function(){return nS(this,function(r){switch(r.label){case 0:return[4,rr("Loading app information...",function(e){return"App found: ".concat(e.title)},function(){return nk(function(){return nS(this,function(r){switch(r.label){case 0:return[4,tq.fetchAppInfo(e)];case 1:return[2,r.sent()]}})})()})];case 1:return[2,r.sent()]}})})()}function nT(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var nx=b.object({name:b.string({required_error:"No name field found in package.json",invalid_type_error:'"name" must be a string in package.json'})});function nA(){var e;return(e=function(){var e,r,t;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){try{if(e=l(process.cwd(),"package.json"),r=JSON.parse(s(e,"utf8")),!(t=nx.safeParse(r)).success)return[2,w({code:"MALFORMED_PACKAGE_JSON",error:t.error})];return[2,m(t.data.name)]}catch(e){var o;if(null!=(o=SyntaxError)&&"undefined"!=typeof Symbol&&o[Symbol.hasInstance]?!!o[Symbol.hasInstance](e):e instanceof o)return[2,w({code:"INVALID_JSON",error:e})];return[2,w({code:"FILE_SYSTEM_ERROR",error:e})]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){nT(a,n,o,i,c,"next",e)}function c(e){nT(a,n,o,i,c,"throw",e)}i(void 0)})})()}var nR=r(e(import.meta.url)),nj=b.object({name:b.literal("attio"),version:b.string({required_error:"No CLI version found",invalid_type_error:"CLI version must be a string in package.json"})});function nP(){if(void 0===em){var e,r,t=ec("package.json",{cwd:nR});if(void 0===t)return w({code:"UNABLE_TO_FIND_PACKAGE_JSON",path:nR});try{e=s(t,"utf8")}catch(e){return w({code:"UNABLE_TO_READ_PACKAGE_JSON",error:e})}try{r=JSON.parse(e)}catch(e){return w({code:"UNABLE_TO_PARSE_PACKAGE_JSON",error:e})}var n=nj.safeParse(r);if(!n.success)return w({code:"INVALID_PACKAGE_JSON",error:n.error});em=n.data}var o=em.version;return o?m(o):w({code:"NO_CLI_VERSION_FOUND"})}function nN(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nC(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){nN(a,n,o,i,c,"next",e)}function c(e){nN(a,n,o,i,c,"throw",e)}i(void 0)})}}function nD(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var nF=".env";function nL(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nU(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nM(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){nU(a,n,o,i,c,"next",e)}function c(e){nU(a,n,o,i,c,"throw",e)}i(void 0)})}}function nG(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function nB(e,r){function t(t){var n=t.toString().trim().toLowerCase();"\x03"!==n&&n===e.toLowerCase()&&r()}return process.stdin.isTTY&&(process.stdin.setRawMode(!0),process.stdin.resume(),process.stdin.setEncoding("utf8"),process.stdin.on("data",t)),function(){process.stdin.isTTY&&(process.stdin.removeListener("data",t),process.stdin.setRawMode(!1),process.stdin.pause())}}var nV=r(e(import.meta.url));function nW(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nJ(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nY(){process.stdout.write('\uD83D\uDEA8 IMPORTANT: You will need to install your app in your workspace. Press "i" to open the app settings page, and then click "Install".\n\n')}function nK(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nH(e,r){var t;return(t=function(){return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(t){switch(t.label){case 0:return t.trys.push([0,2,,3]),[4,fetch(r,{method:"PUT",body:e,headers:{"Content-Type":"text/javascript","Content-Length":String(Buffer.from(e).length)}})];case 1:return t.sent(),[2,m(void 0)];case 2:return t.sent(),[2,w({code:"BUNDLE_UPLOAD_ERROR",upload_url:r})];case 3:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(n,o){var a=t.apply(e,r);function i(e){nK(a,n,o,i,c,"next",e)}function c(e){nK(a,n,o,i,c,"throw",e)}i(void 0)})})()}function nq(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function n$(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nX(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){n$(a,n,o,i,c,"next",e)}function c(e){n$(a,n,o,i,c,"throw",e)}i(void 0)})}}function nz(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function nQ(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function nZ(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function n0(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function n1(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){n0(a,n,o,i,c,"next",e)}function c(e){n0(a,n,o,i,c,"throw",e)}i(void 0)})}}function n2(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var n4=function(e){try{z.notify({title:"TypeScript Error".concat(1===e.length?"":"s"),message:"There ".concat(1===e.length?"was one error":"were ".concat(e.length," errors")," in your TypeScript code")})}catch(e){}},n3=function(e){var r,t,n=((null==(r=e.errors)?void 0:r.length)||0)+((null==(t=e.warnings)?void 0:t.length)||0);try{z.notify({title:"JavaScript ".concat(1===n?"Error":"Errors"),message:"There ".concat(1===n?"was one error":"were ".concat(n," errors")," in your JavaScript code")})}catch(e){}},n6=b.object({workspace:b.string().optional(),app:b.string().optional()}),n5=new d("dev").description("Develop your Attio app").addOption(new h("-w, --workspace <slug>","The slug of the workspace to use")).addOption(new h("-a, --app <slug>","The app slug to use (overrides package.json)")).action(function(e){return n1(function(){var r,n,o,a,i,s,l,f,p,d,h,b,y,E,k,S,T,x,A,P,N,C,D,F;return n2(this,function(L){var U,M,G,B,W,J,K,H,q,$,X,Q,Z,en,ei,ec,el;switch(L.label){case 0:return n=(r=n6.parse(e)).workspace,o=r.app,a=[],i=!1,[4,e0(!0)];case 1:if(O(s=L.sent()))switch(s.error.code){case"APP_ENTRY_POINT_NOT_FOUND":e1("Could not find app.ts");case"FAILED_TO_GENERATE_ENTRY_POINT":e1("Failed to generate app.ts")}return[4,(U=function(){var e,r,t;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:e=u.resolve("."),r=u.join(e,nv),n.label=1;case 1:return n.trys.push([1,7,,13]),[4,I.readFile(r,"utf-8")];case 2:if(n.sent().split(/\r?\n/).includes(e4))return[3,6];n.label=3;case 3:return n.trys.push([3,5,,6]),[4,I.appendFile(r,"\n"+e4+"\n")];case 4:return n.sent(),[3,6];case 5:return n.sent(),[2,w({code:"FAILED_TO_ADD_HIDDEN_FILES_TO_GITIGNORE"})];case 6:return[2,m(void 0)];case 7:if(!((void 0===(t=n.sent())?"undefined":t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t)=="object"&&null!==t&&"code"in t&&"ENOENT"===t.code))return[3,12];n.label=8;case 8:return n.trys.push([8,10,,11]),[4,I.writeFile(nv,nm)];case 9:return n.sent(),[3,11];case 10:return n.sent(),[2,w({code:"FAILED_TO_CREATE_GITIGNORE"})];case 11:return[2,m(void 0)];case 12:return[2,w({code:"FAILED_TO_READ_GITIGNORE"})];case 13:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(t,n){var o=U.apply(e,r);function a(e){ny(o,t,n,a,i,"next",e)}function i(e){ny(o,t,n,a,i,"throw",e)}a(void 0)})})()];case 2:return L.sent(),[4,(M=function(){var e,r,t,n,o,a;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(i){switch(i.label){case 0:return e=u.resolve("./tsconfig.json"),[4,g(I.readFile(e,"utf-8"))];case 1:var c,s,l;if(O(r=i.sent())){if((void 0===(t=r.error)?"undefined":t&&"undefined"!=typeof Symbol&&t.constructor===Symbol?"symbol":typeof t)=="object"&&null!==t&&"code"in t&&"ENOENT"===t.code)return[2,w({code:"TS_CONFIG_NOT_FOUND"})];return[2,w({code:"FAILED_TO_READ_TSCONFIG"})]}if(O(n=_(function(){return nb.parse(JSON.parse(r.value))})))return[2,w({code:"FAILED_TO_PARSE_TSCONFIG"})];if(o="".concat(e4,"/**/*"),n.value.include.includes(o))return[2,m(!1)];return s=function(e){for(var r=1;r<arguments.length;r++){var t=null!=arguments[r]?arguments[r]:{},n=Object.keys(t);"function"==typeof Object.getOwnPropertySymbols&&(n=n.concat(Object.getOwnPropertySymbols(t).filter(function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),n.forEach(function(r){var n;n=t[r],r in e?Object.defineProperty(e,r,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[r]=n})}return e}({},n.value),l=l={include:((function(e){if(Array.isArray(e))return nd(e)})(c=n.value.include)||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(c)||function(e,r){if(e){if("string"==typeof e)return nd(e,void 0);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return nd(e,void 0)}}(c)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([o])},Object.getOwnPropertyDescriptors?Object.defineProperties(s,Object.getOwnPropertyDescriptors(l)):(function(e,r){var t=Object.keys(e);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(e);t.push.apply(t,n)}return t})(Object(l)).forEach(function(e){Object.defineProperty(s,e,Object.getOwnPropertyDescriptor(l,e))}),a=s,[4,g(I.writeFile(e,JSON.stringify(a,null,2)))];case 2:if(O(i.sent()))return[2,w({code:"FAILED_TO_WRITE_TSCONFIG"})];return[2,m(!0)]}})},function(){var e=this,r=arguments;return new Promise(function(t,n){var o=M.apply(e,r);function a(e){nh(o,t,n,a,i,"next",e)}function i(e){nh(o,t,n,a,i,"throw",e)}a(void 0)})})()];case 3:if(O(l=L.sent()))switch(l.error.code){case"TS_CONFIG_NOT_FOUND":case"FAILED_TO_READ_TSCONFIG":case"FAILED_TO_PARSE_TSCONFIG":case"FAILED_TO_WRITE_TSCONFIG":process.stderr.write(R.yellow('Failed to update tsconfig. Make sure the "include" field contains the '.concat(e4," directory \n")));break;default:throw Error(l.error)}return[4,e5()];case 4:return O(L.sent())&&e1("Failed to generate settings types"),[4,np.ensureAuthed()];case 5:L.sent(),f=function(){return n1(function(){var e,r,t,n,o,c,s,u,l;return n2(this,function(f){switch(f.label){case 0:if(i)return[2];i=!0,f.label=1;case 1:f.trys.push([1,12,,13]),e=!0,r=!1,t=void 0,f.label=2;case 2:f.trys.push([2,9,10,11]),n=a.reverse()[Symbol.iterator](),f.label=3;case 3:if(e=(o=n.next()).done)return[3,8];c=o.value,f.label=4;case 4:return f.trys.push([4,6,,7]),[4,Promise.race([c(),new Promise(function(e,r){return setTimeout(function(){return r(Error("Cleanup timeout"))},2e3)})])];case 5:return f.sent(),[3,7];case 6:return s=f.sent(),process.stderr.write(R.yellow("Warning during cleanup: ".concat(s,"\n"))),[3,7];case 7:return e=!0,[3,3];case 8:return[3,11];case 9:return u=f.sent(),r=!0,t=u,[3,11];case 10:try{e||null==n.return||n.return()}finally{if(r)throw t}return[7];case 11:return[3,13];case 12:return l=f.sent(),process.stderr.write(R.red("Error during cleanup: ".concat(l,"\n"))),[3,13];case 13:return[2]}})})()},L.label=6;case 6:return L.trys.push([6,9,,11]),[4,function(e){var r;return(r=function(e){var r,t,n,o,a,i,s,u,l,f,p,d,h,b;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(y){switch(y.label){case 0:if(r=e.workspaceSlug,!(t=e.appSlug))return[3,1];return o=m(t),[3,3];case 1:return[4,nA()];case 2:o=y.sent(),y.label=3;case 3:return O(n=o)&&(tz(n.error),process.exit(1)),[4,nI(a=n.value)];case 4:return O(i=y.sent())&&(tX(i.error),process.exit(1)),s=i.value,[4,nE(r)];case 5:return O(u=y.sent())&&(tZ(u.error),process.exit(1)),l=u.value,[4,nC(function(){var e;return nD(this,function(r){switch(r.label){case 0:return[4,nC(function(){return nD(this,function(e){switch(e.label){case 0:return e.trys.push([0,2,,3]),[4,c.access(nF)];case 1:return e.sent(),[2,!0];case 2:return e.sent(),[2,!1];case 3:return[2]}})})()];case 1:if(!r.sent())return[2,{}];return[4,c.readFile(nF,{encoding:"utf8"})];case 2:e=r.sent();try{return[2,es.parse(e)]}catch(e){throw Error("Failed to parse ".concat(nF))}}})})()];case 6:return f=y.sent(),O(p=nP())&&(tQ(p),process.exit(1)),d=p.value,[4,tq.createDevVersion({appId:s.app_id,cliVersion:d,targetWorkspaceId:l.workspace_id,environmentVariables:f})];case 7:return O(h=y.sent())&&(t$("Error creating dev version",h.error),process.exit(1)),b=h.value,[2,{appId:s.app_id,appSlug:a,devVersionId:b.app_dev_version_id,workspace:l}]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(e){nL(a,n,o,i,c,"next",e)}function c(e){nL(a,n,o,i,c,"throw",e)}i(void 0)})}).apply(this,arguments)}({workspaceSlug:n,appSlug:o})];case 7:return d=(p=L.sent()).appId,h=p.appSlug,b=p.workspace,y=p.devVersionId,B=null,W=!1,(J=function(){var e,r,n,o,a,i,c;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(s){switch(s.label){case 0:if(W)return[2];s.label=1;case 1:return s.trys.push([1,3,,4]),e=nV,r=u.resolve(e,"..","..","schema.graphql"),n=t.readFileSync(r,"utf8"),[4,t6(8700)];case 2:return G=s.sent(),o=Y(n),a=new er,i=function(){return{}},a.use("/graphql",eu({schema:o,rootResolver:i,graphiql:!0})),B=ee({fetch:a.fetch,port:G}),process.stdout.write('\n\n Press "o" to open GraphQL Explorer.\n\n'),[3,4];case 3:throw c=s.sent(),process.stderr.write("Failed to start GraphQL server: ".concat(c,"\n")),c;case 4:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(t,n){var o=J.apply(e,r);function a(e){nW(o,t,n,a,i,"next",e)}function i(e){nW(o,t,n,a,i,"throw",e)}a(void 0)})})().catch(function(e){process.stderr.write("GraphQL server failed to start: ".concat(e,"\n"))}),K=nB("o",function(){G&&et("http://localhost:".concat(G,"/graphql"))}),E=function(){if(W=!0,K(),B)try{B.close()}catch(e){process.stderr.write("Error closing GraphQL server: ".concat(e,"\n"))}},a.push(E),q=(H={appId:d,appSlug:h,workspace:b}).appId,$=H.appSlug,X=H.workspace,Q=nB("i",function(){et("".concat(tg,"/").concat(X.slug,"/settings/apps/").concat($))}),(Z=function(){var e,r,t;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:return[4,tq.fetchInstallation({appId:q,workspaceId:X.workspace_id})];case 1:if(O(e=n.sent()))return[2];if(r=e.value)return[3,6];nY(),n.label=2;case 2:if(r)return[3,5];return[4,new Promise(function(e){return setTimeout(e,6e4)})];case 3:return n.sent(),[4,tq.fetchInstallation({appId:q,workspaceId:X.workspace_id})];case 4:if(O(t=n.sent()))return[2];return(r=t.value)||nY(),[3,2];case 5:Q(),n.label=6;case 6:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(t,n){var o=Z.apply(e,r);function a(e){nJ(o,t,n,a,i,"next",e)}function i(e){nJ(o,t,n,a,i,"throw",e)}a(void 0)})})(),k=Q,a.push(k),S=!1,en=function(e,r){var t=!1,n=V.watch(["src/**/*.ts","src/**/*.tsx"],{ignored:["**/node_modules/**","**/dist/**","**/*.graphql.d.ts","**/*.gql.d.ts"],cwd:".",persistent:!0,awaitWriteFinish:{stabilityThreshold:100,pollInterval:100}});function o(){var n;return(n=function(){var n,o,a,i;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(c){switch(c.label){case 0:if(t)return[2];c.label=1;case 1:return c.trys.push([1,4,,5]),[4,rs(u.resolve("tsconfig.json"))];case 2:if("Not a TypeScript project"===(n=c.sent()))return null==e||e(),[2];return[4,ru(n)];case 3:return(o=c.sent()).length?null==r||r(o):null==e||e(),[3,5];case 4:var s;if((void 0===(a=c.sent())?"undefined":a&&"undefined"!=typeof Symbol&&a.constructor===Symbol?"symbol":typeof a)=="object"&&null!==a&&"code"in a&&("ENOENT"===a.code||"EACCES"===a.code||"EPERM"===a.code))throw a;return(null!=(s=Error)&&"undefined"!=typeof Symbol&&s[Symbol.hasInstance]?!!s[Symbol.hasInstance](a):a instanceof s)&&(i=rc.parse({text:a.message}),null==r||r([i])),[3,5];case 5:return[2]}})},function(){var e=this,r=arguments;return new Promise(function(t,o){var a=n.apply(e,r);function i(e){nQ(a,t,o,i,c,"next",e)}function c(e){nQ(a,t,o,i,c,"throw",e)}i(void 0)})})()}var a=!1;return n.on("ready",function(){a=!0,n.on("all",function(e,r){("add"===e||"change"===e||"unlink"===e)&&o()})}),n.on("error",function(e){process.stderr.write("TypeScript watcher error: ".concat(e,"\n"))}),[function(){if(t=!0,a)try{n.close()}catch(e){process.stderr.write("Error closing TypeScript watcher: ".concat(e,"\n"))}},o]}(function(){S&&(process.stdout.write("".concat(R.green("✓")," TypeScript errors fixed\n")),S=!1)},function(e){S=!0,e.forEach(rl),n4(e)}),x=(T=function(e){if(Array.isArray(e))return e}(en)||function(e,r){var t,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(t=o.next()).done)&&(a.push(t.value),2!==a.length);i=!0);}catch(e){c=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw n}}return a}}(en,2)||function(e,r){if(e){if("string"==typeof e)return nZ(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return nZ(e,2)}}(en,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],A=T[1],a.push(x),P=!1,ei=function(){P&&(process.stdout.write("".concat(R.green("✓")," GraphQL errors fixed\n")),P=!1),A()},ec=function(e){P=!0,process.stderr.write(e)},(el=V.watch(["**/*.graphql","**/*.gql"],{ignored:["**/node_modules/**","**/dist/**"],cwd:"."})).on("ready",function(){return tf(function(){var e;return td(this,function(r){switch(r.label){case 0:return[4,th()];case 1:return O(e=r.sent())?"GRAPHQL_ERROR"===e.error.code?null==ec||ec(e.error.error.toString()):e1(e.error.error.toString()):null==ei||ei(),el.on("all",function(e,r){return tf(function(){var r;return td(this,function(t){switch(t.label){case 0:if("add"!==e&&"change"!==e&&"unlink"!==e)return[3,2];return[4,th()];case 1:O(r=t.sent())?"GRAPHQL_ERROR"===r.error.code?null==ec||ec(r.error.error.toString()):e1(r.error.error.toString()):null==ei||ei(),t.label=2;case 2:return[2]}})})()}),[2]}})})()}),N=function(){el.close()},a.push(N),C=!1,D=function(e,r){var t,n=V.watch(["./src/**/*.{js,jsx,ts,tsx}"],{ignored:["**/node_modules/**","**/dist/**","**/*.graphql.d.ts","**/*.gql.d.ts"],cwd:process.cwd()}),o=!1,a=!1,i=!1;function c(){return nM(function(){var r,n,s;return nG(this,function(u){switch(u.label){case 0:if(o||i)return a=!0,[2,m(void 0)];o=!0,u.label=1;case 1:if(u.trys.push([1,,8,9]),t)return[3,3];return[4,rQ("in-memory")];case 2:if(O(r=u.sent()))return[2,r];t=r.value,u.label=3;case 3:return[4,t.rebuild()];case 4:if(O(n=u.sent()))return[2,n];return s=n.value,[4,null==e?void 0:e([s.client.outputFiles[0].text,s.server.outputFiles[0].text])];case 5:if(u.sent(),o=!1,!(a&&!i))return[3,7];return a=!1,[4,c()];case 6:return[2,u.sent()];case 7:return[2,m(void 0)];case 8:return o=!1,[7];case 9:return[2]}})})()}return n.on("ready",function(){return nM(function(){var e;return nG(this,function(t){switch(t.label){case 0:return[4,c()];case 1:return O(e=t.sent())&&(null==r||r(e.error)),n.on("all",function(e){return nM(function(){var t;return nG(this,function(n){switch(n.label){case 0:if("add"!==e&&"change"!==e&&"unlink"!==e)return[3,2];return[4,c()];case 1:O(t=n.sent())&&(null==r||r(t.error)),n.label=2;case 2:return[2]}})})()}),[2]}})})()}),function(){return nM(function(){var e;return nG(this,function(r){switch(r.label){case 0:if(i=!0,!o)return[3,2];return[4,new Promise(function(e){var r=setInterval(function(){o||(clearInterval(r),e(void 0))},10)})];case 1:r.sent(),r.label=2;case 2:return[4,n.close()];case 3:if(r.sent(),!t)return[3,5];return[4,t.dispose(1e3)];case 4:O(e=r.sent())&&process.stderr.write("Error disposing build context: ".concat(e.error,"\n")),t=void 0,r.label=5;case 5:return[2]}})})()}}(function(e){return n1(function(){var r;return n2(this,function(t){switch(t.label){case 0:return C&&(process.stdout.write("".concat(R.green("✓")," Bundling errors fixed\n")),C=!1),[4,function(e){return nX(function(e){var r,t,n;return nz(this,function(o){switch(o.label){case 0:return r=e.contents,t=e.devVersionId,n=e.appId,[4,rr("Uploading...",function(){return"Upload complete at ".concat(new Date().toLocaleTimeString())},function(){return nX(function(){var e,o,a,i,c,s,u,l,f,p;return nz(this,function(d){switch(d.label){case 0:return[4,tq.startUpload({appId:n,devVersionId:t})];case 1:if(O(e=d.sent()))return[2,e];return a=(o=e.value).client_bundle_upload_url,i=o.server_bundle_upload_url,c=o.app_dev_version_bundle_id,u=(s=function(e){if(Array.isArray(e))return e}(r)||function(e,r){var t,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(t=o.next()).done)&&(a.push(t.value),2!==a.length);i=!0);}catch(e){c=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw n}}return a}}(r,2)||function(e,r){if(e){if("string"==typeof e)return nq(e,2);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return nq(e,2)}}(r,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],l=s[1],[4,v([nH(u,a),nH(l,i)])];case 2:if(O(f=d.sent()))return[2,f];return[4,tq.completeBundleUpload({appId:n,devVersionId:t,bundleId:c})];case 3:if(O(p=d.sent()))return[2,p];try{z.notify({title:"Upload Complete",message:"New bundle uploaded to Attio"})}catch(e){}return[2,m(void 0)]}})})()})];case 1:return[2,o.sent()]}})}).apply(this,arguments)}({contents:e,devVersionId:y,appId:d})];case 1:return O(r=t.sent())&&function(e){switch(e.code){case"BUNDLE_UPLOAD_ERROR":process.stderr.write(R.red("Error uploading bundle: ".concat(e.upload_url,"\n")));break;case"START_UPLOAD_ERROR":t$("Error starting upload",e);break;case"COMPLETE_BUNDLE_UPLOAD_ERROR":t$("Error completing bundle upload",e);break;default:return}}(r.error),[2]}})})()},function(e){return n1(function(){var r,t;return n2(this,function(n){return C=!0,"BUILD_JAVASCRIPT_ERROR"===e.code?(n3(e),r=e.errors,t=e.warnings,null==r||r.forEach(function(e){return rf(e,"error")}),null==t||t.forEach(function(e){return rf(e,"warning")})):rZ(e),[2]})})()}),a.push(D),eo.block(),ea.hide(),j.cursorTo(process.stdout,0),process.stdout.write("\n\uD83D\uDC40 Watching for changes..."),j.clearLine(process.stdout,1),process.on("SIGINT",function(){return n1(function(){return n2(this,function(e){switch(e.label){case 0:return[4,f()];case 1:return e.sent(),process.exit(0),[2]}})})()}),process.on("SIGTERM",function(){return n1(function(){return n2(this,function(e){switch(e.label){case 0:return[4,f()];case 1:return e.sent(),process.exit(0),[2]}})})()}),process.on("uncaughtException",function(e){return n1(function(){return n2(this,function(r){switch(r.label){case 0:return process.stderr.write(R.red("Uncaught exception: ".concat(e,"\n"))),[4,f()];case 1:return r.sent(),process.exit(1),[2]}})})()}),process.on("unhandledRejection",function(e){return n1(function(){return n2(this,function(r){switch(r.label){case 0:return process.stderr.write(R.red("Unhandled rejection: ".concat(e,"\n"))),[4,f()];case 1:return r.sent(),process.exit(1),[2]}})})()}),[4,new Promise(function(){})];case 8:return L.sent(),[3,11];case 9:return F=L.sent(),process.stderr.write(R.red("✖ ".concat(F,"\n"))),[4,f()];case 10:return L.sent(),process.exit(1),[3,11];case 11:return[2]}})})()}),n7=function(e){try{return n(f(e),o.W_OK),!0}catch(e){return!1}};function n8(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function n9(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){n8(a,n,o,i,c,"next",e)}function c(e){n8(a,n,o,i,c,"throw",e)}i(void 0)})}}function oe(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function or(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var ot=function(e){var r;return(r=function(){var r,t;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(n){switch(n.label){case 0:t=l(r=process.cwd(),e),n.label=1;case 1:return n.trys.push([1,5,,6]),[4,c.access(t).then(function(){return!0}).catch(function(){return!1})];case 2:if(n.sent())return[2,w({code:"DIRECTORY_ALREADY_EXISTS",path:t})];return[4,c.access(r,o.W_OK)];case 3:return n.sent(),[4,c.mkdir(t)];case 4:return n.sent(),[2,m(t)];case 5:return n.sent(),[2,w({code:"WRITE_ACCESS_DENIED",path:e})];case 6:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(e){or(a,n,o,i,c,"next",e)}function c(e){or(a,n,o,i,c,"throw",e)}i(void 0)})})()},on=r(e(import.meta.url));function oo(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function oa(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){oo(a,n,o,i,c,"next",e)}function c(e){oo(a,n,o,i,c,"throw",e)}i(void 0)})}}function oi(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function oc(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var os=b.string(),ou=new d("init").description("Initialize a new Attio app").addArgument(new p("<app-slug>","The app slug, chosen in the developer dashboard")).action(function(e){var r;return(r=function(){var r,t,n,o,a;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(s){switch(s.label){case 0:return s.trys.push([0,4,,5]),process.stdout.write("\n".concat(" *@@@@#= ++:\n #@@@@# :# :+# =+@ @@+\n #@@@@# + +++ :++ -*@@::::@@@:: --. +++:\n #@@@@+ :: :%@@@@@@@@ @@@@@@@@@@@@@ @@+ :#@@@@@@=\n #@@@@: *:++++ :@@+ +@@@ +@@ @@@ @@+:@@# +@@+\n #@@@@: *:#@@# + *@# +@@ +@@ @@@ @@++@@ +@@\n@@@@@- + #@@# + +@@: :@@@ +@@ @@@ @@+=@@: #@#\n:@@@@%: + #@@@@: :: #@@@+@@@@@ :@@@@+ +@@@@ @@+ +@@@+#@@#\n :@@@@@+ #@@@@+: :++++++++ :+++: ++++ ++: +++++:","\n\n")),r=os.parse(e),[4,np.ensureAuthed()];case 1:return s.sent(),[4,nI(r)];case 2:return O(t=s.sent())&&(tX(t.error),process.exit(1)),n=t.value,[4,function(e){return oa(function(e){var r,t;return oi(this,function(n){switch(n.label){case 0:return r=e.appSlug,t=e.appInfo,[4,rr("Creating project...","Project created",function(){return oa(function(){var e,n,o,a,s;return oi(this,function(l){switch(l.label){case 0:if(e=process.cwd(),i(n=u.join(e,r)))return[2,w({code:"DIRECTORY_ALREADY_EXISTS",path:n})];if(!n7(e))return[2,w({code:"WRITE_ACCESS_DENIED",path:e})];return[4,ot(r)];case 1:if(O(o=l.sent()))return[2,o];return a=o.value,[4,function e(r,t,n){return n9(function(){var o,a;return oe(this,function(i){switch(i.label){case 0:return i.trys.push([0,2,,3]),[4,c.mkdir(t,{recursive:!0})];case 1:return i.sent(),[3,3];case 2:return i.sent(),[2,w({code:"FAILED_TO_CREATE_DIRECTORY",path:t})];case 3:return i.trys.push([3,5,,6]),[4,c.readdir(r,{withFileTypes:!0})];case 4:return o=i.sent(),[3,6];case 5:return i.sent(),[2,w({code:"FAILED_TO_LIST_FILES",path:r})];case 6:return[4,v(o.map(function(o){return n9(function(){var a,i,s;return oe(this,function(l){switch(l.label){case 0:if(a=u.join(r,o.name),i=u.join(t,o.name),!o.isDirectory())return[3,2];return[4,e(a,i,n)];case 1:return[2,l.sent()];case 2:if(!o.isFile())return[3,14];if(!(o.name.startsWith(".")||/\.(jpg|jpeg|png|gif|svg|webp|ico)$/i.test(o.name)))return[3,7];l.label=3;case 3:return l.trys.push([3,5,,6]),[4,c.copyFile(a,i)];case 4:return l.sent(),[3,6];case 5:return l.sent(),[2,w({code:"FAILED_TO_COPY_FILE",src:a,dest:i})];case 6:return[3,14];case 7:return l.trys.push([7,9,,10]),[4,c.readFile(a,"utf8")];case 8:return s=l.sent(),[3,10];case 9:return l.sent(),[2,w({code:"FAILED_TO_READ_FILE",path:a})];case 10:s=n(s),l.label=11;case 11:return l.trys.push([11,13,,14]),[4,c.writeFile(i,s,"utf8")];case 12:return l.sent(),[3,14];case 13:return l.sent(),[2,w({code:"FAILED_TO_WRITE_FILE",path:i})];case 14:return[2,m(void 0)]}})})()}))];case 7:if(O(a=i.sent()))return[2,a];return[2,m(void 0)]}})})()}(u.resolve(on,"../template"),a,function(e){return e.replaceAll("title-to-be-replaced",t.title).replaceAll("id-to-be-replaced",t.app_id).replaceAll("slug-to-be-replaced",r)})];case 2:if(O(s=l.sent()))return[2,s];return[2,m(void 0)]}})})()})];case 1:return[2,n.sent()]}})}).apply(this,arguments)}({appSlug:r,appInfo:n})];case 3:return O(o=s.sent())&&(!function(e){switch(e.code){case"DIRECTORY_ALREADY_EXISTS":process.stderr.write(R.red("✖ Directory ".concat(e.path," already exists.\n")));break;case"WRITE_ACCESS_DENIED":process.stderr.write(R.red("✖ Write access denied to ".concat(e.path,"\n")));break;case"FAILED_TO_CREATE_DIRECTORY":process.stderr.write(R.red("✖ Failed to create directory ".concat(e.path,"\n")));break;case"FAILED_TO_COPY_FILE":process.stderr.write(R.red("✖ Failed to copy file ".concat(e.src," to ").concat(e.dest,"\n")));break;case"FAILED_TO_LIST_FILES":process.stderr.write(R.red("✖ Failed to list files in ".concat(e.path,"\n")));break;case"FAILED_TO_READ_FILE":process.stderr.write(R.red("✖ Failed to read file ".concat(e.path,"\n")));break;case"FAILED_TO_WRITE_FILE":process.stderr.write(R.red("✖ Failed to write file ".concat(e.path,"\n")));break;default:return}}(o.error),process.exit(1)),process.stdout.write("".concat(R.green("SUCCESS!! \uD83C\uDF89 Your app directory has been created."),"\n\nTo get started, run:\n\n").concat(el("cd ".concat(r,"\nnpm install\nnpm run dev"),{padding:1,margin:1,borderStyle:"round"}),"\n\n(").concat(R.yellow("yarn"),", ").concat(R.yellow("pnpm"),", and ").concat(R.yellow("bun")," also work!)\n")),process.exit(0),[3,5];case 4:return a=s.sent(),process.stderr.write("".concat(R.red("✖ ".concat(a)),"\n")),process.exit(1),[3,5];case 5:return[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(e){oc(a,n,o,i,c,"next",e)}function c(e){oc(a,n,o,i,c,"throw",e)}i(void 0)})})()});function ol(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var of=new d("login").description("Authenticate with Attio").action(function(){var e;return(e=function(){var e;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){switch(r.label){case 0:return[4,np.authenticate()];case 1:return O(e=r.sent())&&(!function(e){switch(e.code){case"GET_TOKEN_ERROR":t$("Error getting token",e);break;case"REFRESH_TOKEN_ERROR":t$("Error refreshing token",e);break;case"NO_AUTHORIZATION_CODE":process.stderr.write(R.red("No authorization code received"));break;case"OAUTH_STATE_MISMATCH":process.stderr.write(R.red("OAuth state mismatch, possible CSRF attack"));break;case"SAVE_KEYCHAIN_ERROR":case"LOAD_KEYCHAIN_ERROR":case"DELETE_KEYCHAIN_ERROR":t0(e);break;default:return}}(e.error),process.exit(1)),process.stdout.write("\uD83D\uDD13 Successfully authenticated.\n"),process.exit(0),[2]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){ol(a,n,o,i,c,"next",e)}function c(e){ol(a,n,o,i,c,"throw",e)}i(void 0)})})()});function op(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var od=new d("logout").description("Log out from Attio").action(function(){var e;return(e=function(){var e;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(r){switch(r.label){case 0:return[4,nc().delete()];case 1:return O(e=r.sent())&&(t0(e.error),process.exit(1)),process.stdout.write("\uD83D\uDD12 Successfully logged out.\n"),process.exit(0),[2]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){op(a,n,o,i,c,"next",e)}function c(e){op(a,n,o,i,c,"throw",e)}i(void 0)})})()});function oh(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function ob(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function oy(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){ob(a,n,o,i,c,"next",e)}function c(e){ob(a,n,o,i,c,"throw",e)}i(void 0)})}}function ov(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}function om(e,r){return function(e){if(Array.isArray(e))return e}(e)||function(e,r){var t,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(t=o.next()).done)&&(a.push(t.value),!r||a.length!==r);i=!0);}catch(e){c=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw n}}return a}}(e,r)||function(e,r){if(e){if("string"==typeof e)return oh(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return oh(e,r)}}(e,r)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()}function ow(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function og(e){return w({code:"FAILED_TO_CONNECT_TO_REALTIME_SERVER",error:e})}var o_=function(){"use strict";var e;function r(){if(!(this instanceof r))throw TypeError("Cannot call a class as a function");ov(this,"_ablyRealtime",void 0),ov(this,"_channels",new Map),ov(this,"_suspendListeners",new Set),this._ablyRealtime=this._createAblyRealtime()}return e=[{key:"subscribe",value:function(e,r,t,n){return oy(function(){var o,a,i,c,s;return ow(this,function(u){switch(u.label){case 0:if(o=this,a=this._channels.get(e))return[3,2];return a={listeners:new Map},[4,this._authorizeChannel(e)];case 1:if(O(i=u.sent()))return[2,og(i.error.error)];this._channels.set(e,a),u.label=2;case 2:return(c=a.listeners.get(r))||(c=new Set,a.listeners.set(r,c)),[4,this._subscribe(e,r,function(e){var r=t.safeParse(e);r.success&&n(r.data)})];case 3:if(O(s=u.sent()))return[2,og(s.error.error)];return c.add(n),[2,m({unsubscribe:function(){return oy(function(){return ow(this,function(t){switch(t.label){case 0:return[4,this._unsubscribe(e,r,n)];case 1:return t.sent(),[2]}})}).call(o)}})]}})}).call(this)}},{key:"reconnect",value:function(){return oy(function(){var e,r,t,n,o,a,i,c,s,u,l,f,p,d,h,b,y,v,w,g,_,E,k,S,I;return ow(this,function(T){switch(T.label){case 0:return[4,this._teardown()];case 1:T.sent(),this._ablyRealtime=this._createAblyRealtime(),e=!0,r=!1,t=void 0,T.label=2;case 2:T.trys.push([2,20,21,22]),n=this._channels[Symbol.iterator](),T.label=3;case 3:if(e=(o=n.next()).done)return[3,19];return i=(a=om(o.value,2))[0],c=a[1].listeners,[4,this._authorizeChannel(i)];case 4:if(O(s=T.sent()))return[2,og(s.error.error)];u=!0,l=!1,f=void 0,T.label=5;case 5:T.trys.push([5,16,17,18]),p=c[Symbol.iterator](),T.label=6;case 6:if(u=(d=p.next()).done)return[3,15];b=(h=om(d.value,2))[0],y=h[1],v=!0,w=!1,g=void 0,T.label=7;case 7:T.trys.push([7,12,13,14]),_=y[Symbol.iterator](),T.label=8;case 8:if(v=(E=_.next()).done)return[3,11];return k=E.value,[4,this._subscribe(i,b,k)];case 9:if(O(S=T.sent()))return[2,og(S.error.error)];T.label=10;case 10:return v=!0,[3,8];case 11:return[3,14];case 12:return I=T.sent(),w=!0,g=I,[3,14];case 13:try{v||null==_.return||_.return()}finally{if(w)throw g}return[7];case 14:return u=!0,[3,6];case 15:return[3,18];case 16:return I=T.sent(),l=!0,f=I,[3,18];case 17:try{u||null==p.return||p.return()}finally{if(l)throw f}return[7];case 18:return e=!0,[3,3];case 19:return[3,22];case 20:return I=T.sent(),r=!0,t=I,[3,22];case 21:try{e||null==n.return||n.return()}finally{if(r)throw t}return[7];case 22:return[2,m(!0)]}})}).call(this)}},{key:"onSuspended",value:function(e){var r=this;return this._suspendListeners.add(e),function(){r._suspendListeners.delete(e)}}},{key:"close",value:function(){return oy(function(){return ow(this,function(e){switch(e.label){case 0:return[4,this._teardown()];case 1:return e.sent(),[2]}})}).call(this)}},{key:"_createAblyRealtime",value:function(){var e=this,r=new ep.Realtime({logLevel:0,useTokenAuth:!0,autoConnect:!1,tls:!0,echoMessages:!1,authCallback:function(e,r){return oy(function(){var t;return ow(this,function(n){switch(n.label){case 0:return[4,tq.authenticateAbly(e)];case 1:if(O(t=n.sent()))return[2,r(t.error.message,null)];return[2,r(null,t.value)]}})})()}});return r.connection.on("suspended",function(){e._suspendListeners.forEach(function(e){return e()})}),r}},{key:"_authorizeChannel",value:function(e){return oy(function(){return ow(this,function(r){switch(r.label){case 0:return r.trys.push([0,2,,3]),[4,this._ablyRealtime.auth.authorize({capability:ov({},"".concat(e),["subscribe"])})];case 1:return r.sent(),[2,m(!0)];case 2:return[2,w({code:"FAILED_TO_AUTHORIZE_CHANNEL",error:r.sent()})];case 3:return[2]}})}).call(this)}},{key:"_subscribe",value:function(e,r,t){return oy(function(){var n;return ow(this,function(o){switch(o.label){case 0:return o.trys.push([0,3,,4]),[4,(n=this._ablyRealtime.channels.get(e)).presence.enter()];case 1:return o.sent(),[4,n.subscribe(r,function(e){t(e.data.data)})];case 2:return o.sent(),[2,m(!0)];case 3:return[2,w({code:"FAILED_TO_SUBSCRIBE_TO_EVENTS",error:o.sent()})];case 4:return[2]}})}).call(this)}},{key:"_unsubscribe",value:function(e,r,t){return oy(function(){var n,o;return ow(this,function(a){switch(a.label){case 0:if(this._ablyRealtime.channels.get(e).unsubscribe(r,t),!(n=this._channels.get(e)))return[2,m(!0)];if((o=n.listeners.get(r))&&(o.delete(t),(null==o?void 0:o.size)===0&&n.listeners.delete(r)),0!==n.listeners.size)return[3,2];return[4,this._teardownChannel(e)];case 1:E(a.sent())&&this._channels.delete(e),a.label=2;case 2:return[2,m(!0)]}})}).call(this)}},{key:"_teardown",value:function(){return oy(function(){var e,r,t,n,o,a,i;return ow(this,function(c){switch(c.label){case 0:e=!0,r=!1,t=void 0,c.label=1;case 1:c.trys.push([1,6,7,8]),n=this._channels[Symbol.iterator](),c.label=2;case 2:if(e=(o=n.next()).done)return[3,5];return a=om(o.value,1)[0],[4,this._teardownChannel(a)];case 3:c.sent(),c.label=4;case 4:return e=!0,[3,2];case 5:return[3,8];case 6:return i=c.sent(),r=!0,t=i,[3,8];case 7:try{e||null==n.return||n.return()}finally{if(r)throw t}return[7];case 8:return this._ablyRealtime.close(),[2,m(!0)]}})}).call(this)}},{key:"_teardownChannel",value:function(e){return oy(function(){var r;return ow(this,function(t){switch(t.label){case 0:r=this._ablyRealtime.channels.get(e),t.label=1;case 1:return t.trys.push([1,4,,5]),[4,r.presence.leave()];case 2:return t.sent(),[4,r.detach()];case 3:return t.sent(),[2,m(!0)];case 4:return[2,w({code:"FAILED_TO_TEARDOWN_CHANNEL",error:t.sent()})];case 5:return[2]}})}).call(this)}}],function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,e),r}(),oE=b.union([b.literal("INFO"),b.literal("WARNING"),b.literal("ERROR")]),oO=b.object({message:b.string(),severity:oE,timestamp:b.string().datetime()});function ok(e,r,t){return r in e?Object.defineProperty(e,r,{value:t,enumerable:!0,configurable:!0,writable:!0}):e[r]=t,e}var oS=function(){"use strict";var e;function r(e){var t=this;if(!(this instanceof r))throw TypeError("Cannot call a class as a function");ok(this,"bufferDelayMs",void 0),ok(this,"buffer",void 0),ok(this,"listeners",void 0),ok(this,"flushInterval",void 0),this.bufferDelayMs=e,this.buffer=[],this.listeners=[],this.flushInterval=setInterval(function(){t.flush()},e/5)}return e=[{key:"close",value:function(){this.flushInterval&&clearInterval(this.flushInterval),this.flushInterval=null}},{key:"listen",value:function(e){this.assertNotClosed(),this.listeners.push(e)}},{key:"add",value:function(e){this.assertNotClosed();var r=Date.now(),t=this.buffer.findIndex(function(r){return e.timestamp>r.event.timestamp});t>=0?this.buffer.splice(t,0,{event:e,receivedAt:r}):this.buffer.push({event:e,receivedAt:r})}},{key:"flush",value:function(){var e=this,r=Date.now(),t=this.buffer.findIndex(function(t){return r-t.receivedAt>e.bufferDelayMs});if(-1!==t){var n=this.buffer.splice(t,this.buffer.length-t).reverse().map(function(e){return e.event}),o=!0,a=!1,i=void 0;try{for(var c,s=this.listeners[Symbol.iterator]();!(o=(c=s.next()).done);o=!0)(0,c.value)(n)}catch(e){a=!0,i=e}finally{try{o||null==s.return||s.return()}finally{if(a)throw i}}}}},{key:"assertNotClosed",value:function(){if(null===this.flushInterval)throw Error("This buffer was closed")}}],function(e,r){for(var t=0;t<r.length;t++){var n=r[t];n.enumerable=n.enumerable||!1,n.configurable=!0,"value"in n&&(n.writable=!0),Object.defineProperty(e,n.key,n)}}(r.prototype,e),r}();function oI(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function oT(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){oI(a,n,o,i,c,"next",e)}function c(e){oI(a,n,o,i,c,"throw",e)}i(void 0)})}}function ox(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function oA(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function oR(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){oA(a,n,o,i,c,"next",e)}function c(e){oA(a,n,o,i,c,"throw",e)}i(void 0)})}}function oj(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var oP=b.object({workspace:b.string().optional(),app:b.string().optional()}),oN=new d("logs").description("Stream development server logs").addOption(new h("-w, --workspace <slug>","The slug of the workspace to get the logs from")).addOption(new h("-a, --app <slug>","The app slug to use (overrides package.json)")).action(function(e){return oR(function(){var r,t,n,o,a,i,c,s,u,l,f,p,d,h;return oj(this,function(b){switch(b.label){case 0:return t=(r=oP.parse(e)).workspace,n=r.app,[4,np.ensureAuthed()];case 1:if(b.sent(),!n)return[3,2];return a=m(n),[3,4];case 2:return[4,nA()];case 3:a=b.sent(),b.label=4;case 4:return O(o=a)&&(tz(o.error),process.exit(1)),[4,nI(o.value)];case 5:return O(i=b.sent())&&(tX(i.error),process.exit(1)),c=i.value,[4,nE(t)];case 6:return O(s=b.sent())&&(tZ(s.error),process.exit(1)),u=s.value,l=ef.createInterface({input:process.stdin,output:process.stdout}),f=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:"Press Enter to resume...";return oR(function(){return oj(this,function(r){switch(r.label){case 0:return[4,l.question(e)];case 1:return r.sent(),[2]}})})()},[4,rr("Connecting to log server...","Connected to log server",function(){return oR(function(){return oj(this,function(e){return[2,function(e,r,t){return oT(function(e,r,t){var n,o,a,i,c,s,u;return ox(this,function(l){switch(l.label){case 0:return n=e.workspaceId,o=e.appId,(a=new oS(200)).listen(function(e){return e.forEach(r)}),(i=new o_).onSuspended(function(){t({close:function(){return oT(function(){return ox(this,function(e){switch(e.label){case 0:return[4,i.close()];case 1:return e.sent(),[2]}})})()},reconnect:function(){return oT(function(){var e;return ox(this,function(r){switch(r.label){case 0:return[4,i.reconnect()];case 1:if(O(e=r.sent()))return[2,w({code:"FAILED_TO_CONNECT_TO_LOGS_SERVER",error:e.error.error})];return[2,m(!0)]}})})()}})}),c="ecosystem-app-logs:".concat(n,":").concat(o),[4,i.subscribe(c,"app-dev-log-emitted",oO,function(e){a.add(e)})];case 1:if(O(s=l.sent()))return[2,w({code:"FAILED_TO_CONNECT_TO_LOGS_SERVER",error:s.error.error})];return u=s.value,[2,m({unsubscribe:function(){return oT(function(){return ox(this,function(e){switch(e.label){case 0:return a.close(),[4,u.unsubscribe()];case 1:return e.sent(),[2]}})})()}})]}})}).apply(this,arguments)}({workspaceId:u.workspace_id,appId:c.app_id},function(e){var r,t=e.message,n=e.severity,o=e.timestamp;switch(n){case"INFO":r=R.blue(n);break;case"ERROR":r=R.red(n);break;case"WARNING":r=R.yellow(n);break;default:r=n}var a="".concat(o," ").concat(r,": ").concat(t.trim());process.stdout.write("\n".concat(a))},function(e){var r=e.close,t=e.reconnect;return oR(function(){var e;return oj(this,function(n){switch(n.label){case 0:return[4,r()];case 1:return n.sent(),[4,f("The connection to the logs server was closed. Press Enter to reconnect...")];case 2:return n.sent(),[4,rr("Connecting to log server...","Connected to log server",function(){return t()})];case 3:return O(e=n.sent())&&(t1(e.error),process.exit(2)),[2]}})})()})]})})()}).finally(function(){l.close()})];case 7:return O(p=b.sent())&&(t1(p.error),process.exit(2)),d=!1,h=function(){var e=arguments.length>0&&void 0!==arguments[0]?arguments[0]:0;return oR(function(){return oj(this,function(r){switch(r.label){case 0:if(d)return[2];d=!0,r.label=1;case 1:return r.trys.push([1,3,4,5]),[4,p.value.unsubscribe()];case 2:return r.sent(),[3,5];case 3:return r.sent(),e=Math.min(e,1),[3,5];case 4:return process.exit(e),[7];case 5:return[2]}})})()},["SIGINT","SIGTERM"].forEach(function(e){return process.on(e,function(){return oR(function(){return oj(this,function(e){return[2,h(0)]})})()})}),process.on("beforeExit",function(e){return oR(function(){return oj(this,function(r){switch(r.label){case 0:return[4,h(e)];case 1:return r.sent(),[2]}})})()}),process.on("uncaughtException",function(e){return oR(function(){return oj(this,function(r){switch(r.label){case 0:return process.stderr.write(R.red("Uncaught exception: ".concat(e,"\n"))),[4,h(1)];case 1:return r.sent(),[2]}})})()}),process.on("unhandledRejection",function(e){return oR(function(){return oj(this,function(r){switch(r.label){case 0:return process.stderr.write(R.red("Unhandled rejection: ".concat(e,"\n"))),[4,h(1)];case 1:return r.sent(),[2]}})})()}),[4,new Promise(function(){})];case 8:return b.sent(),[2]}})})()});function oC(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function oD(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){oC(a,n,o,i,c,"next",e)}function c(e){oC(a,n,o,i,c,"throw",e)}i(void 0)})}}function oF(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}function oL(e){return oD(function(){return oF(this,function(r){switch(r.label){case 0:return[4,rr("Loading versions...","Versions loaded",function(){return oD(function(){return oF(this,function(r){switch(r.label){case 0:return[4,tq.fetchVersions(e.app_id)];case 1:return[2,r.sent()]}})})()})];case 1:return[2,r.sent()]}})})()}function oU(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function oM(){var e;return(e=function(){var e,r,t,n,o,a,i;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(c){switch(c.label){case 0:if("true"===(r=null!=(e=process.env.ATTIO_COVERAGE)?e:"").toLowerCase()||"1"===r)return[2,w({code:"COVERAGE_ENABLED_IN_PRODUCTION"})];return[4,rQ("in-memory")];case 1:if(O(t=c.sent()))return[2,w({code:"ERROR_PREPARING_BUILD_CONTEXT",error:t.error})];return[4,(n=t.value).rebuild()];case 2:if(O(o=c.sent()))return[2,w({code:"ERROR_BUILDING_BUNDLE",error:o.error})];return a=o.value,[4,n.dispose(1e3)];case 3:if(O(i=c.sent()))return[2,w({code:"ERROR_DISPOSING_BUILD_CONTEXT",error:i.error})];return[2,m([a.client.outputFiles[0].text,a.server.outputFiles[0].text])]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){oU(a,n,o,i,c,"next",e)}function c(e){oU(a,n,o,i,c,"throw",e)}i(void 0)})})()}function oG(e,r){(null==r||r>e.length)&&(r=e.length);for(var t=0,n=Array(r);t<r;t++)n[t]=e[t];return n}function oB(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}function oV(e){return function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){oB(a,n,o,i,c,"next",e)}function c(e){oB(a,n,o,i,c,"throw",e)}i(void 0)})}}function oW(e,r){if(e){if("string"==typeof e)return oG(e,r);var t=Object.prototype.toString.call(e).slice(8,-1);if("Object"===t&&e.constructor&&(t=e.constructor.name),"Map"===t||"Set"===t)return Array.from(t);if("Arguments"===t||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t))return oG(e,r)}}function oJ(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}var oY=b.object({app:b.string().optional()}),oK=new d("create").description("Create a new unpublished version of your Attio app").addOption(new h("-a, --app <slug>","The app slug to use (overrides package.json)")).action(function(e){return oV(function(){var r,t,n,o,a,i,c,s,u,l,f,p,d,h,b,y,w;return oJ(this,function(g){switch(g.label){case 0:return[4,e0()];case 1:return O(g.sent())&&e2(),[4,np.ensureAuthed()];case 2:if(g.sent(),!(r=oY.parse(e).app))return[3,3];return n=m(r),[3,5];case 3:return[4,nA()];case 4:n=g.sent(),g.label=5;case 5:return O(t=n)&&(tz(t.error),process.exit(1)),[4,nI(t.value)];case 6:return O(o=g.sent())&&(tX(o.error),process.exit(1)),a=o.value,[4,rr("Bundling JavaScript...","Bundling complete",oM)];case 7:var _;return O(i=g.sent())&&("COVERAGE_ENABLED_IN_PRODUCTION"===i.error.code?process.stderr.write("".concat(R.red("✖ "),"ATTIO_COVERAGE must not be set when creating production versions.\n")+" Unset the environment variable and try again.\n"):"ERROR_BUILDING_BUNDLE"===i.error.code?"BUILD_JAVASCRIPT_ERROR"===(c=i.error.error).code?(s=c.errors,u=c.warnings,null==s||s.forEach(function(e){return rf(e,"error")}),null==u||u.forEach(function(e){return rf(e,"warning")})):rZ(c):rZ(i.error.error),process.exit(1)),_=i.value,f=(l=function(e){if(Array.isArray(e))return e}(_)||function(e,r){var t,n,o=null==e?null:"undefined"!=typeof Symbol&&e[Symbol.iterator]||e["@@iterator"];if(null!=o){var a=[],i=!0,c=!1;try{for(o=o.call(e);!(i=(t=o.next()).done)&&(a.push(t.value),2!==a.length);i=!0);}catch(e){c=!0,n=e}finally{try{i||null==o.return||o.return()}finally{if(c)throw n}}return a}}(_,2)||oW(_,2)||function(){throw TypeError("Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}())[0],p=l[1],[4,oL(a)];case 8:return O(d=g.sent())&&(t$("Error fetching versions",d.error),process.exit(1)),h=d.value,[4,rr("Uploading...","Upload complete",function(){return oV(function(){var e,r,t,n,o,i,c,s;return oJ(this,function(u){switch(u.label){case 0:var l;return O(r=nP())&&(tQ(r),process.exit(1)),t=r.value,[4,tq.createVersion({appId:a.app_id,major:0===h.length?1:(e=Math).max.apply(e,((function(e){if(Array.isArray(e))return oG(e)})(l=h.map(function(e){return e.major}))||function(e){if("undefined"!=typeof Symbol&&null!=e[Symbol.iterator]||null!=e["@@iterator"])return Array.from(e)}(l)||oW(l)||function(){throw TypeError("Invalid attempt to spread non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.")}()).concat([1])),cliVersion:t})];case 1:return O(n=u.sent())&&(t$("Error creating version",n.error),process.exit(1)),i=(o=n.value).client_bundle_upload_url,c=o.server_bundle_upload_url,[4,v([nH(f,i),nH(p,c)])];case 2:return O(s=u.sent())&&(process.stderr.write("".concat(R.red("✖ "),"Failed to upload bundle to: ").concat(s.error.upload_url,"\n")),process.exit(1)),[2,n]}})})()})];case 9:return O(b=g.sent())&&(process.stderr.write("".concat(R.red("✖ "),"Failed to create version: ").concat(b.error,"\n")),process.exit(1)),y=b.value,[4,rr("Signing bundles...","Bundles signed",function(){return oV(function(){return oJ(this,function(e){switch(e.label){case 0:return[4,tq.completeProdBundleUpload({appId:a.app_id,major:y.major,minor:y.minor,bundleId:y.app_prod_version_bundle_id})];case 1:return[2,e.sent()]}})})()})];case 10:return O(w=g.sent())&&(t$("Error signing bundles",w.error),process.exit(1)),process.stdout.write("\nVersion ".concat(R.green("".concat(y.major,".").concat(y.minor))," created!\n\n")),process.exit(0),[2]}})})()});function oH(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var oq=b.object({app:b.string().optional()}),o$=new d().name("list").description("List all versions of your app").addOption(new h("-a, --app <slug>","The app slug to use (overrides package.json)")).action(function(e){var r;return(r=function(){var r,t,n,o,a,i,c;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(s){switch(s.label){case 0:return[4,np.ensureAuthed()];case 1:if(s.sent(),!(r=oq.parse(e).app))return[3,2];return n=m(r),[3,4];case 2:return[4,nA()];case 3:n=s.sent(),s.label=4;case 4:return O(t=n)&&(tz(t.error),process.exit(1)),[4,nI(t.value)];case 5:return O(o=s.sent())&&(tX(o.error),process.exit(1)),[4,oL(o.value)];case 6:return O(a=s.sent())&&(t$("Error loading versions",a.error),process.exit(1)),0===(i=a.value).length&&(process.stdout.write("No versions found\n"),process.exit(0)),c=new ed({head:["Version","Status","Published","Installations","Created"].map(function(e){return R.bold(e)}),style:{head:[],border:[]},colAligns:["center","left","center","right","left"]}),i.forEach(function(e){var r={private:R.gray,"in-review":R.yellow,published:R.green,rejected:R.red},t=e.publication_status.split("_").map(function(e){return e.charAt(0).toUpperCase()+e.slice(1)}).join(" ");c.push(["".concat(e.major,".").concat(e.minor),r[e.publication_status](t),e.is_published?"Yes":"No",e.num_installations.toLocaleString(),eh(new Date(e.created_at),"MMM d, yyyy, HH:mm")])}),process.stdout.write("\n"+c.toString()+"\n"),process.exit(0),[2]}})},function(){var e=this,t=arguments;return new Promise(function(n,o){var a=r.apply(e,t);function i(e){oH(a,n,o,i,c,"next",e)}function c(e){oH(a,n,o,i,c,"throw",e)}i(void 0)})})()}),oX=new d("version").description("Manage app versions").addCommand(oK).addCommand(o$);function oz(e,r,t,n,o,a,i){try{var c=e[a](i),s=c.value}catch(e){t(e);return}c.done?r(s):Promise.resolve(s).then(n,o)}var oQ=new d().name("whoami").description("Identify the current user").action(function(){var e;return(e=function(){var e,r,t,n,o;return function(e,r){var t,n,o,a={label:0,sent:function(){if(1&o[0])throw o[1];return o[1]},trys:[],ops:[]},i=Object.create(("function"==typeof Iterator?Iterator:Object).prototype);return i.next=c(0),i.throw=c(1),i.return=c(2),"function"==typeof Symbol&&(i[Symbol.iterator]=function(){return this}),i;function c(c){return function(s){var u=[c,s];if(t)throw TypeError("Generator is already executing.");for(;i&&(i=0,u[0]&&(a=0)),a;)try{if(t=1,n&&(o=2&u[0]?n.return:u[0]?n.throw||((o=n.return)&&o.call(n),0):n.next)&&!(o=o.call(n,u[1])).done)return o;switch(n=0,o&&(u=[2&u[0],o.value]),u[0]){case 0:case 1:o=u;break;case 4:return a.label++,{value:u[1],done:!1};case 5:a.label++,n=u[1],u=[0];continue;case 7:u=a.ops.pop(),a.trys.pop();continue;default:if(!(o=(o=a.trys).length>0&&o[o.length-1])&&(6===u[0]||2===u[0])){a=0;continue}if(3===u[0]&&(!o||u[1]>o[0]&&u[1]<o[3])){a.label=u[1];break}if(6===u[0]&&a.label<o[1]){a.label=o[1],o=u;break}if(o&&a.label<o[2]){a.label=o[2],a.ops.push(u);break}o[2]&&a.ops.pop(),a.trys.pop();continue}u=r.call(e,a)}catch(e){u=[6,e],n=0}finally{t=o=0}if(5&u[0])throw u[1];return{value:u[0]?u[1]:void 0,done:!0}}}}(this,function(a){switch(a.label){case 0:return[4,nc().load()];case 1:return(O(e=a.sent())||null===e.value)&&(process.stdout.write("\uD83D\uDD12 Not logged in.\n"),process.exit(0)),[4,tq.whoami()];case 2:return O(r=a.sent())&&(t$("Error fetching user",r.error),process.exit(1)),n=(t=r.value).name,o=t.email_address,process.stdout.write("\uD83D\uDC64 ".concat(n.full," (").concat(o,")\n")),process.exit(0),[2]}})},function(){var r=this,t=arguments;return new Promise(function(n,o){var a=e.apply(r,t);function i(e){oz(a,n,o,i,c,"next",e)}function c(e){oz(a,n,o,i,c,"throw",e)}i(void 0)})})()}),oZ=r(e(import.meta.url)),o0=b.object({version:b.string()}).parse(JSON.parse(s(l(oZ,"../../package.json"),"utf-8")));new d().name("attio").description("CLI tool to create Attio apps").version(o0.version).addCommand(ou).addCommand(ty).addCommand(n5).addCommand(oX).addCommand(of).addCommand(od).addCommand(oQ).addCommand(oN).parse();
|