@activepieces/piece-chatwoot 0.0.3 → 0.0.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,16 +1,11 @@
1
1
  {
2
2
  "name": "@activepieces/piece-chatwoot",
3
- "version": "0.0.3",
3
+ "version": "0.0.5",
4
4
  "main": "./src/index.js",
5
- "types": "./src/index.d.ts",
6
- "scripts": {
7
- "build": "tsc -p tsconfig.lib.json && cp package.json dist/",
8
- "lint": "eslint 'src/**/*.ts'"
9
- },
10
- "dependencies": {
11
- "@activepieces/pieces-common": "0.12.3",
12
- "@activepieces/pieces-framework": "0.30.0",
13
- "@activepieces/shared": "0.87.1",
14
- "tslib": "2.6.2"
15
- }
5
+ "dependencies": {},
6
+ "files": [
7
+ "src/index.js",
8
+ "package.json",
9
+ "src/i18n"
10
+ ]
16
11
  }
package/src/index.js CHANGED
@@ -1,36 +1,30 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.chatwoot = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const send_message_1 = require("./lib/actions/send-message");
7
- const new_message_1 = require("./lib/triggers/new-message");
8
- const auth_1 = require("./lib/auth");
9
- const pieces_common_1 = require("@activepieces/pieces-common");
10
- const types_1 = require("./lib/common/types");
11
- const constants_1 = require("./lib/common/constants");
12
- exports.chatwoot = (0, pieces_framework_1.createPiece)({
13
- displayName: 'Chatwoot',
14
- description: 'Receive and reply to customer messages with Chatwoot',
15
- auth: auth_1.chatwootAuth,
16
- minimumSupportedRelease: '0.30.0',
17
- logoUrl: 'https://cdn.activepieces.com/pieces/chatwoot.png',
18
- authors: ['AhmadTash'],
19
- actions: [send_message_1.sendMessage,
20
- (0, pieces_common_1.createCustomApiCallAction)({
21
- auth: auth_1.chatwootAuth,
22
- baseUrl: (auth) => {
23
- const authValue = (0, types_1.getChatwootAuth)(auth);
24
- return authValue.baseUrl;
25
- },
26
- authMapping: (auth) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
27
- const authValue = (0, types_1.getChatwootAuth)(auth);
28
- return {
29
- [constants_1.CHATWOOT_AUTH_HEADER]: authValue.apiAccessToken,
30
- };
31
- }),
32
- })
33
- ],
34
- triggers: [new_message_1.newMessage],
35
- });
36
- //# sourceMappingURL=index.js.map
1
+ "use strict";var tu=Object.create;var Je=Object.defineProperty;var ru=Object.getOwnPropertyDescriptor;var nu=Object.getOwnPropertyNames;var ou=Object.getPrototypeOf,iu=Object.prototype.hasOwnProperty;var o=(e,t)=>Je(e,"name",{value:t,configurable:!0});var E=(e,t)=>()=>{try{return t||e((t={exports:{}}).exports,t),t.exports}catch(r){throw t=0,r}},vn=(e,t)=>{for(var r in t)Je(e,r,{get:t[r],enumerable:!0})},xn=(e,t,r,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of nu(t))!iu.call(e,i)&&i!==r&&Je(e,i,{get:()=>t[i],enumerable:!(n=ru(t,i))||n.enumerable});return e};var Ce=(e,t,r)=>(r=e!=null?tu(ou(e)):{},xn(t||!e||!e.__esModule?Je(r,"default",{value:e,enumerable:!0}):r,e)),au=e=>xn(Je({},"__esModule",{value:!0}),e);var Zo=E((Bo,Wt)=>{(function(e){"use strict";let t="(0?\\d+|0x[a-f0-9]+)",r={fourOctet:new RegExp(`^${t}\\.${t}\\.${t}\\.${t}$`,"i"),threeOctet:new RegExp(`^${t}\\.${t}\\.${t}$`,"i"),twoOctet:new RegExp(`^${t}\\.${t}$`,"i"),longValue:new RegExp(`^${t}$`,"i")},n=new RegExp("^0[0-7]+$","i"),i=new RegExp("^0x[a-f0-9]+$","i"),u="%[0-9a-z]{1,}",c="(?:[0-9a-f]+::?)+",p={zoneIndex:new RegExp(u,"i"),native:new RegExp(`^(::)?(${c})?([0-9a-f]+)?(::)?(${u})?$`,"i"),deprecatedTransitional:new RegExp(`^(?:::)(${t}\\.${t}\\.${t}\\.${t}(${u})?)$`,"i"),transitional:new RegExp(`^((?:${c})|(?:::)(?:${c})?)${t}\\.${t}\\.${t}\\.${t}(${u})?$`,"i")};function f(s,d){if(s.indexOf("::")!==s.lastIndexOf("::"))return null;let y=0,m=-1,v=(s.match(p.zoneIndex)||[])[0],P,M;for(v&&(v=v.substring(1),s=s.replace(/%.+$/,""));(m=s.indexOf(":",m+1))>=0;)y++;if(s.substr(0,2)==="::"&&y--,s.substr(-2,2)==="::"&&y--,y>d)return null;for(M=d-y,P=":";M--;)P+="0:";return s=s.replace("::",P),s[0]===":"&&(s=s.slice(1)),s[s.length-1]===":"&&(s=s.slice(0,-1)),d=(function(){let Q=s.split(":"),oe=[];for(let Ke=0;Ke<Q.length;Ke++)oe.push(parseInt(Q[Ke],16));return oe})(),{parts:d,zoneId:v}}o(f,"expandIPv6");function g(s,d,y,m){if(s.length!==d.length)throw new Error("ipaddr: cannot match CIDR for objects with different lengths");let v=0,P;for(;m>0;){if(P=y-m,P<0&&(P=0),s[v]>>P!==d[v]>>P)return!1;m-=y,v+=1}return!0}o(g,"matchCIDR");function x(s){if(i.test(s))return parseInt(s,16);if(s[0]==="0"&&!isNaN(parseInt(s[1],10))){if(n.test(s))return parseInt(s,8);throw new Error(`ipaddr: cannot parse ${s} as octal`)}return parseInt(s,10)}o(x,"parseIntAuto");function b(s,d){for(;s.length<d;)s=`0${s}`;return s}o(b,"padPart");let _={};_.IPv4=(function(){function s(d){if(d.length!==4)throw new Error("ipaddr: ipv4 octet count should be 4");let y,m;for(y=0;y<d.length;y++)if(m=d[y],!(0<=m&&m<=255))throw new Error("ipaddr: ipv4 octet should fit in 8 bits");this.octets=d}return o(s,"IPv4"),s.prototype.SpecialRanges={unspecified:[[new s([0,0,0,0]),8]],broadcast:[[new s([255,255,255,255]),32]],multicast:[[new s([224,0,0,0]),4]],linkLocal:[[new s([169,254,0,0]),16]],loopback:[[new s([127,0,0,0]),8]],carrierGradeNat:[[new s([100,64,0,0]),10]],private:[[new s([10,0,0,0]),8],[new s([172,16,0,0]),12],[new s([192,168,0,0]),16]],reserved:[[new s([192,0,0,0]),24],[new s([192,0,2,0]),24],[new s([192,88,99,0]),24],[new s([198,18,0,0]),15],[new s([198,51,100,0]),24],[new s([203,0,113,0]),24],[new s([240,0,0,0]),4]],as112:[[new s([192,175,48,0]),24],[new s([192,31,196,0]),24]],amt:[[new s([192,52,193,0]),24]]},s.prototype.kind=function(){return"ipv4"},s.prototype.match=function(d,y){let m;if(y===void 0&&(m=d,d=m[0],y=m[1]),d.kind()!=="ipv4")throw new Error("ipaddr: cannot match ipv4 address with non-ipv4 one");return g(this.octets,d.octets,8,y)},s.prototype.prefixLengthFromSubnetMask=function(){let d=0,y=!1,m={0:8,128:7,192:6,224:5,240:4,248:3,252:2,254:1,255:0},v,P,M;for(v=3;v>=0;v-=1)if(P=this.octets[v],P in m){if(M=m[P],y&&M!==0)return null;M!==8&&(y=!0),d+=M}else return null;return 32-d},s.prototype.range=function(){return _.subnetMatch(this,this.SpecialRanges)},s.prototype.toByteArray=function(){return this.octets.slice(0)},s.prototype.toIPv4MappedAddress=function(){return _.IPv6.parse(`::ffff:${this.toString()}`)},s.prototype.toNormalizedString=function(){return this.toString()},s.prototype.toString=function(){return this.octets.join(".")},s})(),_.IPv4.broadcastAddressFromCIDR=function(s){try{let d=this.parseCIDR(s),y=d[0].toByteArray(),m=this.subnetMaskFromPrefixLength(d[1]).toByteArray(),v=[],P=0;for(;P<4;)v.push(parseInt(y[P],10)|parseInt(m[P],10)^255),P++;return new this(v)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},_.IPv4.isIPv4=function(s){return this.parser(s)!==null},_.IPv4.isValid=function(s){try{return new this(this.parser(s)),!0}catch{return!1}},_.IPv4.isValidCIDR=function(s){try{return this.parseCIDR(s),!0}catch{return!1}},_.IPv4.isValidFourPartDecimal=function(s){return!!(_.IPv4.isValid(s)&&s.match(/^(0|[1-9]\d*)(\.(0|[1-9]\d*)){3}$/))},_.IPv4.isValidCIDRFourPartDecimal=function(s){let d=s.match(/^(.+)\/(\d+)$/);return!_.IPv4.isValidCIDR(s)||!d?!1:_.IPv4.isValidFourPartDecimal(d[1])},_.IPv4.networkAddressFromCIDR=function(s){let d,y,m,v,P;try{for(d=this.parseCIDR(s),m=d[0].toByteArray(),P=this.subnetMaskFromPrefixLength(d[1]).toByteArray(),v=[],y=0;y<4;)v.push(parseInt(m[y],10)&parseInt(P[y],10)),y++;return new this(v)}catch{throw new Error("ipaddr: the address does not have IPv4 CIDR format")}},_.IPv4.parse=function(s){let d=this.parser(s);if(d===null)throw new Error("ipaddr: string is not formatted like an IPv4 Address");return new this(d)},_.IPv4.parseCIDR=function(s){let d;if(d=s.match(/^(.+)\/(\d+)$/)){let y=parseInt(d[2]);if(y>=0&&y<=32){let m=[this.parse(d[1]),y];return Object.defineProperty(m,"toString",{value:o(function(){return this.join("/")},"value")}),m}}throw new Error("ipaddr: string is not formatted like an IPv4 CIDR range")},_.IPv4.parser=function(s){let d,y,m;if(d=s.match(r.fourOctet))return(function(){let v=d.slice(1,6),P=[];for(let M=0;M<v.length;M++)y=v[M],P.push(x(y));return P})();if(d=s.match(r.longValue)){if(m=x(d[1]),m>4294967295||m<0)throw new Error("ipaddr: address outside defined range");return(function(){let v=[],P;for(P=0;P<=24;P+=8)v.push(m>>P&255);return v})().reverse()}else return(d=s.match(r.twoOctet))?(function(){let v=d.slice(1,4),P=[];if(m=x(v[1]),m>16777215||m<0)throw new Error("ipaddr: address outside defined range");return P.push(x(v[0])),P.push(m>>16&255),P.push(m>>8&255),P.push(m&255),P})():(d=s.match(r.threeOctet))?(function(){let v=d.slice(1,5),P=[];if(m=x(v[2]),m>65535||m<0)throw new Error("ipaddr: address outside defined range");return P.push(x(v[0])),P.push(x(v[1])),P.push(m>>8&255),P.push(m&255),P})():null},_.IPv4.subnetMaskFromPrefixLength=function(s){if(s=parseInt(s),s<0||s>32)throw new Error("ipaddr: invalid IPv4 prefix length");let d=[0,0,0,0],y=0,m=Math.floor(s/8);for(;y<m;)d[y]=255,y++;return m<4&&(d[m]=Math.pow(2,s%8)-1<<8-s%8),new this(d)},_.IPv6=(function(){function s(d,y){let m,v;if(d.length===16)for(this.parts=[],m=0;m<=14;m+=2)this.parts.push(d[m]<<8|d[m+1]);else if(d.length===8)this.parts=d;else throw new Error("ipaddr: ipv6 part count should be 8 or 16");for(m=0;m<this.parts.length;m++)if(v=this.parts[m],!(0<=v&&v<=65535))throw new Error("ipaddr: ipv6 part should fit in 16 bits");y&&(this.zoneId=y)}return o(s,"IPv6"),s.prototype.SpecialRanges={unspecified:[new s([0,0,0,0,0,0,0,0]),128],linkLocal:[new s([65152,0,0,0,0,0,0,0]),10],multicast:[new s([65280,0,0,0,0,0,0,0]),8],loopback:[new s([0,0,0,0,0,0,0,1]),128],uniqueLocal:[new s([64512,0,0,0,0,0,0,0]),7],ipv4Mapped:[new s([0,0,0,0,0,65535,0,0]),96],discard:[new s([256,0,0,0,0,0,0,0]),64],rfc6145:[new s([0,0,0,0,65535,0,0,0]),96],rfc6052:[new s([100,65435,0,0,0,0,0,0]),96],"6to4":[new s([8194,0,0,0,0,0,0,0]),16],teredo:[new s([8193,0,0,0,0,0,0,0]),32],benchmarking:[new s([8193,2,0,0,0,0,0,0]),48],amt:[new s([8193,3,0,0,0,0,0,0]),32],as112v6:[[new s([8193,4,274,0,0,0,0,0]),48],[new s([9760,79,32768,0,0,0,0,0]),48]],deprecated:[new s([8193,16,0,0,0,0,0,0]),28],orchid2:[new s([8193,32,0,0,0,0,0,0]),28],droneRemoteIdProtocolEntityTags:[new s([8193,48,0,0,0,0,0,0]),28],reserved:[[new s([8193,0,0,0,0,0,0,0]),23],[new s([8193,3512,0,0,0,0,0,0]),32]]},s.prototype.isIPv4MappedAddress=function(){return this.range()==="ipv4Mapped"},s.prototype.kind=function(){return"ipv6"},s.prototype.match=function(d,y){let m;if(y===void 0&&(m=d,d=m[0],y=m[1]),d.kind()!=="ipv6")throw new Error("ipaddr: cannot match ipv6 address with non-ipv6 one");return g(this.parts,d.parts,16,y)},s.prototype.prefixLengthFromSubnetMask=function(){let d=0,y=!1,m={0:16,32768:15,49152:14,57344:13,61440:12,63488:11,64512:10,65024:9,65280:8,65408:7,65472:6,65504:5,65520:4,65528:3,65532:2,65534:1,65535:0},v,P;for(let M=7;M>=0;M-=1)if(v=this.parts[M],v in m){if(P=m[v],y&&P!==0)return null;P!==16&&(y=!0),d+=P}else return null;return 128-d},s.prototype.range=function(){return _.subnetMatch(this,this.SpecialRanges)},s.prototype.toByteArray=function(){let d,y=[],m=this.parts;for(let v=0;v<m.length;v++)d=m[v],y.push(d>>8),y.push(d&255);return y},s.prototype.toFixedLengthString=function(){let d=(function(){let m=[];for(let v=0;v<this.parts.length;v++)m.push(b(this.parts[v].toString(16),4));return m}).call(this).join(":"),y="";return this.zoneId&&(y=`%${this.zoneId}`),d+y},s.prototype.toIPv4Address=function(){if(!this.isIPv4MappedAddress())throw new Error("ipaddr: trying to convert a generic ipv6 address to ipv4");let d=this.parts.slice(-2),y=d[0],m=d[1];return new _.IPv4([y>>8,y&255,m>>8,m&255])},s.prototype.toNormalizedString=function(){let d=(function(){let m=[];for(let v=0;v<this.parts.length;v++)m.push(this.parts[v].toString(16));return m}).call(this).join(":"),y="";return this.zoneId&&(y=`%${this.zoneId}`),d+y},s.prototype.toRFC5952String=function(){let d=/((^|:)(0(:|$)){2,})/g,y=this.toNormalizedString(),m=0,v=-1,P;for(;P=d.exec(y);)P[0].length>v&&(m=P.index,v=P[0].length);return v<0?y:`${y.substring(0,m)}::${y.substring(m+v)}`},s.prototype.toString=function(){return this.toRFC5952String()},s})(),_.IPv6.broadcastAddressFromCIDR=function(s){try{let d=this.parseCIDR(s),y=d[0].toByteArray(),m=this.subnetMaskFromPrefixLength(d[1]).toByteArray(),v=[],P=0;for(;P<16;)v.push(parseInt(y[P],10)|parseInt(m[P],10)^255),P++;return new this(v)}catch(d){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${d})`)}},_.IPv6.isIPv6=function(s){return this.parser(s)!==null},_.IPv6.isValid=function(s){if(typeof s=="string"&&s.indexOf(":")===-1)return!1;try{let d=this.parser(s);return new this(d.parts,d.zoneId),!0}catch{return!1}},_.IPv6.isValidCIDR=function(s){if(typeof s=="string"&&s.indexOf(":")===-1)return!1;try{return this.parseCIDR(s),!0}catch{return!1}},_.IPv6.networkAddressFromCIDR=function(s){let d,y,m,v,P;try{for(d=this.parseCIDR(s),m=d[0].toByteArray(),P=this.subnetMaskFromPrefixLength(d[1]).toByteArray(),v=[],y=0;y<16;)v.push(parseInt(m[y],10)&parseInt(P[y],10)),y++;return new this(v)}catch(M){throw new Error(`ipaddr: the address does not have IPv6 CIDR format (${M})`)}},_.IPv6.parse=function(s){let d=this.parser(s);if(d.parts===null)throw new Error("ipaddr: string is not formatted like an IPv6 Address");return new this(d.parts,d.zoneId)},_.IPv6.parseCIDR=function(s){let d,y,m;if((y=s.match(/^(.+)\/(\d+)$/))&&(d=parseInt(y[2]),d>=0&&d<=128))return m=[this.parse(y[1]),d],Object.defineProperty(m,"toString",{value:o(function(){return this.join("/")},"value")}),m;throw new Error("ipaddr: string is not formatted like an IPv6 CIDR range")},_.IPv6.parser=function(s){let d,y,m,v,P,M;if(m=s.match(p.deprecatedTransitional))return this.parser(`::ffff:${m[1]}`);if(p.native.test(s))return f(s,8);if((m=s.match(p.transitional))&&(M=m[6]||"",d=m[1],m[1].endsWith("::")||(d=d.slice(0,-1)),d=f(d+M,6),d.parts)){for(P=[parseInt(m[2]),parseInt(m[3]),parseInt(m[4]),parseInt(m[5])],y=0;y<P.length;y++)if(v=P[y],!(0<=v&&v<=255))return null;return d.parts.push(P[0]<<8|P[1]),d.parts.push(P[2]<<8|P[3]),{parts:d.parts,zoneId:d.zoneId}}return null},_.IPv6.subnetMaskFromPrefixLength=function(s){if(s=parseInt(s),s<0||s>128)throw new Error("ipaddr: invalid IPv6 prefix length");let d=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],y=0,m=Math.floor(s/8);for(;y<m;)d[y]=255,y++;return m<16&&(d[m]=Math.pow(2,s%8)-1<<8-s%8),new this(d)},_.fromByteArray=function(s){let d=s.length;if(d===4)return new _.IPv4(s);if(d===16)return new _.IPv6(s);throw new Error("ipaddr: the binary input is neither an IPv6 nor IPv4 address")},_.isValid=function(s){return _.IPv6.isValid(s)||_.IPv4.isValid(s)},_.isValidCIDR=function(s){return _.IPv6.isValidCIDR(s)||_.IPv4.isValidCIDR(s)},_.parse=function(s){if(_.IPv6.isValid(s))return _.IPv6.parse(s);if(_.IPv4.isValid(s))return _.IPv4.parse(s);throw new Error("ipaddr: the address has neither IPv6 nor IPv4 format")},_.parseCIDR=function(s){try{return _.IPv6.parseCIDR(s)}catch{try{return _.IPv4.parseCIDR(s)}catch{throw new Error("ipaddr: the address has neither IPv6 nor IPv4 CIDR format")}}},_.process=function(s){let d=this.parse(s);return d.kind()==="ipv6"&&d.isIPv4MappedAddress()?d.toIPv4Address():d},_.subnetMatch=function(s,d,y){let m,v,P,M;y==null&&(y="unicast");for(v in d)if(Object.prototype.hasOwnProperty.call(d,v)){for(P=d[v],P[0]&&!(P[0]instanceof Array)&&(P=[P]),m=0;m<P.length;m++)if(M=P[m],s.kind()===M[0].kind()&&s.match.apply(s,M))return v}return y},typeof Wt<"u"&&Wt.exports?Wt.exports=_:e.ipaddr=_})(Bo)});var Hi=E((_A,Vi)=>{var Zi=require("stream").Stream,Bp=require("util");Vi.exports=ae;function ae(){this.source=null,this.dataSize=0,this.maxDataSize=1024*1024,this.pauseStream=!0,this._maxDataSizeExceeded=!1,this._released=!1,this._bufferedEvents=[]}o(ae,"DelayedStream");Bp.inherits(ae,Zi);ae.create=function(e,t){var r=new this;t=t||{};for(var n in t)r[n]=t[n];r.source=e;var i=e.emit;return e.emit=function(){return r._handleEmit(arguments),i.apply(e,arguments)},e.on("error",function(){}),r.pauseStream&&e.pause(),r};Object.defineProperty(ae.prototype,"readable",{configurable:!0,enumerable:!0,get:o(function(){return this.source.readable},"get")});ae.prototype.setEncoding=function(){return this.source.setEncoding.apply(this.source,arguments)};ae.prototype.resume=function(){this._released||this.release(),this.source.resume()};ae.prototype.pause=function(){this.source.pause()};ae.prototype.release=function(){this._released=!0,this._bufferedEvents.forEach(function(e){this.emit.apply(this,e)}.bind(this)),this._bufferedEvents=[]};ae.prototype.pipe=function(){var e=Zi.prototype.pipe.apply(this,arguments);return this.resume(),e};ae.prototype._handleEmit=function(e){if(this._released){this.emit.apply(this,e);return}e[0]==="data"&&(this.dataSize+=e[1].length,this._checkIfMaxDataSizeExceeded()),this._bufferedEvents.push(e)};ae.prototype._checkIfMaxDataSizeExceeded=function(){if(!this._maxDataSizeExceeded&&!(this.dataSize<=this.maxDataSize)){this._maxDataSizeExceeded=!0;var e="DelayedStream#maxDataSize of "+this.maxDataSize+" bytes exceeded.";this.emit("error",new Error(e))}}});var Ki=E((bA,qi)=>{var Zp=require("util"),Gi=require("stream").Stream,Wi=Hi();qi.exports=G;function G(){this.writable=!1,this.readable=!0,this.dataSize=0,this.maxDataSize=2*1024*1024,this.pauseStreams=!0,this._released=!1,this._streams=[],this._currentStream=null,this._insideLoop=!1,this._pendingNext=!1}o(G,"CombinedStream");Zp.inherits(G,Gi);G.create=function(e){var t=new this;e=e||{};for(var r in e)t[r]=e[r];return t};G.isStreamLike=function(e){return typeof e!="function"&&typeof e!="string"&&typeof e!="boolean"&&typeof e!="number"&&!Buffer.isBuffer(e)};G.prototype.append=function(e){var t=G.isStreamLike(e);if(t){if(!(e instanceof Wi)){var r=Wi.create(e,{maxDataSize:1/0,pauseStream:this.pauseStreams});e.on("data",this._checkDataSize.bind(this)),e=r}this._handleErrors(e),this.pauseStreams&&e.pause()}return this._streams.push(e),this};G.prototype.pipe=function(e,t){return Gi.prototype.pipe.call(this,e,t),this.resume(),e};G.prototype._getNext=function(){if(this._currentStream=null,this._insideLoop){this._pendingNext=!0;return}this._insideLoop=!0;try{do this._pendingNext=!1,this._realGetNext();while(this._pendingNext)}finally{this._insideLoop=!1}};G.prototype._realGetNext=function(){var e=this._streams.shift();if(typeof e>"u"){this.end();return}if(typeof e!="function"){this._pipeNext(e);return}var t=e;t(function(r){var n=G.isStreamLike(r);n&&(r.on("data",this._checkDataSize.bind(this)),this._handleErrors(r)),this._pipeNext(r)}.bind(this))};G.prototype._pipeNext=function(e){this._currentStream=e;var t=G.isStreamLike(e);if(t){e.on("end",this._getNext.bind(this)),e.pipe(this,{end:!1});return}var r=e;this.write(r),this._getNext()};G.prototype._handleErrors=function(e){var t=this;e.on("error",function(r){t._emitError(r)})};G.prototype.write=function(e){this.emit("data",e)};G.prototype.pause=function(){this.pauseStreams&&(this.pauseStreams&&this._currentStream&&typeof this._currentStream.pause=="function"&&this._currentStream.pause(),this.emit("pause"))};G.prototype.resume=function(){this._released||(this._released=!0,this.writable=!0,this._getNext()),this.pauseStreams&&this._currentStream&&typeof this._currentStream.resume=="function"&&this._currentStream.resume(),this.emit("resume")};G.prototype.end=function(){this._reset(),this.emit("end")};G.prototype.destroy=function(){this._reset(),this.emit("close")};G.prototype._reset=function(){this.writable=!1,this._streams=[],this._currentStream=null};G.prototype._checkDataSize=function(){if(this._updateDataSize(),!(this.dataSize<=this.maxDataSize)){var e="DelayedStream#maxDataSize of "+this.maxDataSize+" bytes exceeded.";this._emitError(new Error(e))}};G.prototype._updateDataSize=function(){this.dataSize=0;var e=this;this._streams.forEach(function(t){t.dataSize&&(e.dataSize+=t.dataSize)}),this._currentStream&&this._currentStream.dataSize&&(this.dataSize+=this._currentStream.dataSize)};G.prototype._emitError=function(e){this._reset(),this.emit("error",e)}});var Xi=E((TA,Ji)=>{"use strict";Ji.exports={"application/json":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["json","map"]},"application/xml":{source:"iana",compressible:!0,extensions:["xml"]},"application/javascript":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["js","mjs"]},"application/pdf":{source:"iana",compressible:!1,extensions:["pdf"]},"application/zip":{source:"iana",compressible:!1,extensions:["zip"]},"application/gzip":{source:"iana",compressible:!1,extensions:["gz"]},"application/octet-stream":{source:"iana",compressible:!1,extensions:["bin","dat"]},"application/msword":{source:"iana",extensions:["doc"]},"application/vnd.openxmlformats-officedocument.wordprocessingml.document":{source:"iana",extensions:["docx"]},"application/vnd.ms-excel":{source:"iana",extensions:["xls"]},"application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":{source:"iana",extensions:["xlsx"]},"application/vnd.ms-powerpoint":{source:"iana",extensions:["ppt"]},"application/vnd.openxmlformats-officedocument.presentationml.presentation":{source:"iana",extensions:["pptx"]},"application/csv":{compressible:!0,extensions:["csv"]},"application/rtf":{source:"iana",compressible:!0,extensions:["rtf"]},"application/x-tar":{source:"apache",compressible:!0,extensions:["tar"]},"application/x-7z-compressed":{source:"apache",compressible:!1,extensions:["7z"]},"application/wasm":{source:"iana",compressible:!0,extensions:["wasm"]},"text/plain":{source:"iana",compressible:!0,charset:"UTF-8",extensions:["txt","text","log"]},"text/html":{source:"iana",compressible:!0,charset:"UTF-8",extensions:["html","htm"]},"text/css":{source:"iana",compressible:!0,charset:"UTF-8",extensions:["css"]},"text/csv":{source:"iana",compressible:!0,charset:"UTF-8",extensions:["csv"]},"text/markdown":{source:"iana",compressible:!0,charset:"UTF-8",extensions:["md","markdown"]},"text/xml":{source:"iana",compressible:!0,extensions:["xml"]},"text/yaml":{compressible:!0,extensions:["yaml","yml"]},"image/png":{source:"iana",compressible:!1,extensions:["png"]},"image/jpeg":{source:"iana",compressible:!1,extensions:["jpeg","jpg","jpe"]},"image/gif":{source:"iana",compressible:!1,extensions:["gif"]},"image/webp":{source:"apache",compressible:!1,extensions:["webp"]},"image/svg+xml":{source:"iana",compressible:!0,extensions:["svg","svgz"]},"image/bmp":{source:"iana",compressible:!0,extensions:["bmp"]},"image/tiff":{source:"iana",compressible:!1,extensions:["tiff","tif"]},"image/x-icon":{source:"apache",compressible:!0,extensions:["ico"]},"image/heic":{source:"iana",compressible:!1,extensions:["heic"]},"image/avif":{source:"iana",compressible:!1,extensions:["avif"]},"audio/mpeg":{source:"iana",compressible:!1,extensions:["mp3","mpga"]},"audio/wav":{compressible:!1,extensions:["wav"]},"audio/ogg":{source:"iana",compressible:!1,extensions:["ogg","oga"]},"audio/webm":{source:"apache",compressible:!1,extensions:["weba"]},"audio/mp4":{source:"iana",compressible:!1,extensions:["m4a"]},"video/mp4":{source:"iana",compressible:!1,extensions:["mp4","m4v"]},"video/mpeg":{source:"iana",compressible:!1,extensions:["mpeg","mpg"]},"video/webm":{source:"iana",compressible:!1,extensions:["webm"]},"video/quicktime":{source:"iana",compressible:!1,extensions:["mov","qt"]},"video/x-msvideo":{source:"iana",compressible:!1,extensions:["avi"]},"font/woff":{source:"iana",compressible:!1,extensions:["woff"]},"font/woff2":{source:"iana",compressible:!1,extensions:["woff2"]},"font/ttf":{source:"iana",compressible:!0,extensions:["ttf"]},"font/otf":{source:"iana",compressible:!0,extensions:["otf"]},"application/ld+json":{source:"iana",compressible:!0,extensions:["jsonld"]},"application/x-www-form-urlencoded":{source:"iana",compressible:!0},"multipart/form-data":{source:"iana"},"application/vnd.api+json":{source:"iana",compressible:!0},"application/manifest+json":{source:"iana",charset:"UTF-8",compressible:!0,extensions:["webmanifest"]},"application/ics":{compressible:!0,extensions:["ics"]},"text/calendar":{source:"iana",compressible:!0,extensions:["ics","ifb"]},"application/x-ndjson":{compressible:!0,extensions:["ndjson"]}}});var ea=E(Y=>{"use strict";var Yt=Xi(),Vp=require("path").extname,Yi=/^\s*([^;\s]*)(?:;|\s|$)/,Hp=/^text\//i;Y.charset=Qi;Y.charsets={lookup:Qi};Y.contentType=Wp;Y.extension=Gp;Y.extensions=Object.create(null);Y.lookup=qp;Y.types=Object.create(null);Kp(Y.extensions,Y.types);function Qi(e){if(!e||typeof e!="string")return!1;var t=Yi.exec(e),r=t&&Yt[t[1].toLowerCase()];return r&&r.charset?r.charset:t&&Hp.test(t[1])?"UTF-8":!1}o(Qi,"charset");function Wp(e){if(!e||typeof e!="string")return!1;var t=e.indexOf("/")===-1?Y.lookup(e):e;if(!t)return!1;if(t.indexOf("charset")===-1){var r=Y.charset(t);r&&(t+="; charset="+r.toLowerCase())}return t}o(Wp,"contentType");function Gp(e){if(!e||typeof e!="string")return!1;var t=Yi.exec(e),r=t&&Y.extensions[t[1].toLowerCase()];return!r||!r.length?!1:r[0]}o(Gp,"extension");function qp(e){if(!e||typeof e!="string")return!1;var t=Vp("x."+e).toLowerCase().substr(1);return t&&Y.types[t]||!1}o(qp,"lookup");function Kp(e,t){var r=["nginx","apache",void 0,"iana"];Object.keys(Yt).forEach(o(function(i){var u=Yt[i],c=u.extensions;if(!(!c||!c.length)){e[i]=c;for(var p=0;p<c.length;p++){var f=c[p];if(t[f]){var g=r.indexOf(Yt[t[f]].source),x=r.indexOf(u.source);if(t[f]!=="application/octet-stream"&&(g>x||g===x&&t[f].substr(0,12)==="application/"))continue}t[f]=i}}},"forEachMimeType"))}o(Kp,"populateMaps")});var ra=E((SA,ta)=>{ta.exports=Jp;function Jp(e){var t=typeof setImmediate=="function"?setImmediate:typeof process=="object"&&typeof process.nextTick=="function"?process.nextTick:null;t?t(e):setTimeout(e,0)}o(Jp,"defer")});var Gr=E((zA,oa)=>{var na=ra();oa.exports=Xp;function Xp(e){var t=!1;return na(function(){t=!0}),o(function(n,i){t?e(n,i):na(o(function(){e(n,i)},"nextTick_callback"))},"async_callback")}o(Xp,"async")});var qr=E((kA,ia)=>{ia.exports=Yp;function Yp(e){Object.keys(e.jobs).forEach(Qp.bind(e)),e.jobs={}}o(Yp,"abort");function Qp(e){typeof this.jobs[e]=="function"&&this.jobs[e]()}o(Qp,"clean")});var Kr=E((RA,sa)=>{var aa=Gr(),el=qr();sa.exports=tl;function tl(e,t,r,n){var i=r.keyedList?r.keyedList[r.index]:r.index;r.jobs[i]=rl(t,i,e[i],function(u,c){i in r.jobs&&(delete r.jobs[i],u?el(r):r.results[i]=c,n(u,r.results))})}o(tl,"iterate");function rl(e,t,r,n){var i;return e.length==2?i=e(r,aa(n)):i=e(r,t,aa(n)),i}o(rl,"runJob")});var Jr=E((DA,ua)=>{ua.exports=nl;function nl(e,t){var r=!Array.isArray(e),n={index:0,keyedList:r||t?Object.keys(e):null,jobs:{},results:r?{}:[],size:r?Object.keys(e).length:e.length};return t&&n.keyedList.sort(r?t:function(i,u){return t(e[i],e[u])}),n}o(nl,"state")});var Xr=E((UA,ca)=>{var ol=qr(),il=Gr();ca.exports=al;function al(e){Object.keys(this.jobs).length&&(this.index=this.size,ol(this),il(e)(null,this.results))}o(al,"terminator")});var la=E((LA,pa)=>{var sl=Kr(),ul=Jr(),cl=Xr();pa.exports=pl;function pl(e,t,r){for(var n=ul(e);n.index<(n.keyedList||e).length;)sl(e,t,n,function(i,u){if(i){r(i,u);return}if(Object.keys(n.jobs).length===0){r(null,n.results);return}}),n.index++;return cl.bind(n,r)}o(pl,"parallel")});var Yr=E((FA,Qt)=>{var da=Kr(),ll=Jr(),dl=Xr();Qt.exports=ml;Qt.exports.ascending=ma;Qt.exports.descending=fl;function ml(e,t,r,n){var i=ll(e,r);return da(e,t,i,o(function u(c,p){if(c){n(c,p);return}if(i.index++,i.index<(i.keyedList||e).length){da(e,t,i,u);return}n(null,i.results)},"iteratorHandler")),dl.bind(i,n)}o(ml,"serialOrdered");function ma(e,t){return e<t?-1:e>t?1:0}o(ma,"ascending");function fl(e,t){return-1*ma(e,t)}o(fl,"descending")});var ga=E((ZA,fa)=>{var gl=Yr();fa.exports=yl;function yl(e,t,r){return gl(e,t,null,r)}o(yl,"serial")});var ha=E((HA,ya)=>{ya.exports={parallel:la(),serial:ga(),serialOrdered:Yr()}});var Qr=E((WA,va)=>{"use strict";va.exports=Object});var _a=E((GA,xa)=>{"use strict";xa.exports=Error});var ba=E((qA,Pa)=>{"use strict";Pa.exports=EvalError});var Ta=E((KA,Ia)=>{"use strict";Ia.exports=RangeError});var $a=E((JA,Ea)=>{"use strict";Ea.exports=ReferenceError});var Aa=E((XA,Sa)=>{"use strict";Sa.exports=SyntaxError});var er=E((YA,za)=>{"use strict";za.exports=TypeError});var ka=E((QA,Oa)=>{"use strict";Oa.exports=URIError});var Ra=E((ez,wa)=>{"use strict";wa.exports=Math.abs});var Da=E((tz,Na)=>{"use strict";Na.exports=Math.floor});var Ua=E((rz,Ca)=>{"use strict";Ca.exports=Math.max});var La=E((nz,Ma)=>{"use strict";Ma.exports=Math.min});var Fa=E((oz,ja)=>{"use strict";ja.exports=Math.pow});var Za=E((iz,Ba)=>{"use strict";Ba.exports=Math.round});var Ha=E((az,Va)=>{"use strict";Va.exports=Number.isNaN||o(function(t){return t!==t},"isNaN")});var Ga=E((uz,Wa)=>{"use strict";var hl=Ha();Wa.exports=o(function(t){return hl(t)||t===0?t:t<0?-1:1},"sign")});var Ka=E((pz,qa)=>{"use strict";qa.exports=Object.getOwnPropertyDescriptor});var en=E((lz,Ja)=>{"use strict";var tr=Ka();if(tr)try{tr([],"length")}catch{tr=null}Ja.exports=tr});var Ya=E((dz,Xa)=>{"use strict";var rr=Object.defineProperty||!1;if(rr)try{rr({},"a",{value:1})}catch{rr=!1}Xa.exports=rr});var tn=E((mz,Qa)=>{"use strict";Qa.exports=o(function(){if(typeof Symbol!="function"||typeof Object.getOwnPropertySymbols!="function")return!1;if(typeof Symbol.iterator=="symbol")return!0;var t={},r=Symbol("test"),n=Object(r);if(typeof r=="string"||Object.prototype.toString.call(r)!=="[object Symbol]"||Object.prototype.toString.call(n)!=="[object Symbol]")return!1;var i=42;t[r]=i;for(var u in t)return!1;if(typeof Object.keys=="function"&&Object.keys(t).length!==0||typeof Object.getOwnPropertyNames=="function"&&Object.getOwnPropertyNames(t).length!==0)return!1;var c=Object.getOwnPropertySymbols(t);if(c.length!==1||c[0]!==r||!Object.prototype.propertyIsEnumerable.call(t,r))return!1;if(typeof Object.getOwnPropertyDescriptor=="function"){var p=Object.getOwnPropertyDescriptor(t,r);if(p.value!==i||p.enumerable!==!0)return!1}return!0},"hasSymbols")});var rs=E((gz,ts)=>{"use strict";var es=typeof Symbol<"u"&&Symbol,vl=tn();ts.exports=o(function(){return typeof es!="function"||typeof Symbol!="function"||typeof es("foo")!="symbol"||typeof Symbol("bar")!="symbol"?!1:vl()},"hasNativeSymbols")});var rn=E((hz,ns)=>{"use strict";ns.exports=typeof Reflect<"u"&&Reflect.getPrototypeOf||null});var nn=E((vz,os)=>{"use strict";var xl=Qr();os.exports=xl.getPrototypeOf||null});var ss=E((xz,as)=>{"use strict";var _l="Function.prototype.bind called on incompatible ",Pl=Object.prototype.toString,bl=Math.max,Il="[object Function]",is=o(function(t,r){for(var n=[],i=0;i<t.length;i+=1)n[i]=t[i];for(var u=0;u<r.length;u+=1)n[u+t.length]=r[u];return n},"concatty"),Tl=o(function(t,r){for(var n=[],i=r||0,u=0;i<t.length;i+=1,u+=1)n[u]=t[i];return n},"slicy"),El=o(function(e,t){for(var r="",n=0;n<e.length;n+=1)r+=e[n],n+1<e.length&&(r+=t);return r},"joiny");as.exports=o(function(t){var r=this;if(typeof r!="function"||Pl.apply(r)!==Il)throw new TypeError(_l+r);for(var n=Tl(arguments,1),i,u=o(function(){if(this instanceof i){var x=r.apply(this,is(n,arguments));return Object(x)===x?x:this}return r.apply(t,is(n,arguments))},"binder"),c=bl(0,r.length-n.length),p=[],f=0;f<c;f++)p[f]="$"+f;if(i=Function("binder","return function ("+El(p,",")+"){ return binder.apply(this,arguments); }")(u),r.prototype){var g=o(function(){},"Empty");g.prototype=r.prototype,i.prototype=new g,g.prototype=null}return i},"bind")});var Ve=E((Pz,us)=>{"use strict";var $l=ss();us.exports=Function.prototype.bind||$l});var nr=E((bz,cs)=>{"use strict";cs.exports=Function.prototype.call});var on=E((Iz,ps)=>{"use strict";ps.exports=Function.prototype.apply});var ds=E((Tz,ls)=>{"use strict";ls.exports=typeof Reflect<"u"&&Reflect&&Reflect.apply});var fs=E((Ez,ms)=>{"use strict";var Sl=Ve(),Al=on(),zl=nr(),Ol=ds();ms.exports=Ol||Sl.call(zl,Al)});var ys=E(($z,gs)=>{"use strict";var kl=Ve(),wl=er(),Rl=nr(),Nl=fs();gs.exports=o(function(t){if(t.length<1||typeof t[0]!="function")throw new wl("a function is required");return Nl(kl,Rl,t)},"callBindBasic")});var bs=E((Az,Ps)=>{"use strict";var Dl=ys(),hs=en(),xs;try{xs=[].__proto__===Array.prototype}catch(e){if(!e||typeof e!="object"||!("code"in e)||e.code!=="ERR_PROTO_ACCESS")throw e}var an=!!xs&&hs&&hs(Object.prototype,"__proto__"),_s=Object,vs=_s.getPrototypeOf;Ps.exports=an&&typeof an.get=="function"?Dl([an.get]):typeof vs=="function"?o(function(t){return vs(t==null?t:_s(t))},"getDunder"):!1});var Ss=E((Oz,$s)=>{"use strict";var Is=rn(),Ts=nn(),Es=bs();$s.exports=Is?o(function(t){return Is(t)},"getProto"):Ts?o(function(t){if(!t||typeof t!="object"&&typeof t!="function")throw new TypeError("getProto: not an object");return Ts(t)},"getProto"):Es?o(function(t){return Es(t)},"getProto"):null});var sn=E((wz,As)=>{"use strict";var Cl=Function.prototype.call,Ul=Object.prototype.hasOwnProperty,Ml=Ve();As.exports=Ml.call(Cl,Ul)});var Ds=E((Rz,Ns)=>{"use strict";var U,Ll=Qr(),jl=_a(),Fl=ba(),Bl=Ta(),Zl=$a(),qe=Aa(),Ge=er(),Vl=ka(),Hl=Ra(),Wl=Da(),Gl=Ua(),ql=La(),Kl=Fa(),Jl=Za(),Xl=Ga(),ws=Function,un=o(function(e){try{return ws('"use strict"; return ('+e+").constructor;")()}catch{}},"getEvalledConstructor"),_t=en(),Yl=Ya(),cn=o(function(){throw new Ge},"throwTypeError"),Ql=_t?(function(){try{return arguments.callee,cn}catch{try{return _t(arguments,"callee").get}catch{return cn}}})():cn,He=rs()(),J=Ss(),ed=nn(),td=rn(),Rs=on(),Pt=nr(),We={},rd=typeof Uint8Array>"u"||!J?U:J(Uint8Array),Ne={__proto__:null,"%AggregateError%":typeof AggregateError>"u"?U:AggregateError,"%Array%":Array,"%ArrayBuffer%":typeof ArrayBuffer>"u"?U:ArrayBuffer,"%ArrayIteratorPrototype%":He&&J?J([][Symbol.iterator]()):U,"%AsyncFromSyncIteratorPrototype%":U,"%AsyncFunction%":We,"%AsyncGenerator%":We,"%AsyncGeneratorFunction%":We,"%AsyncIteratorPrototype%":We,"%Atomics%":typeof Atomics>"u"?U:Atomics,"%BigInt%":typeof BigInt>"u"?U:BigInt,"%BigInt64Array%":typeof BigInt64Array>"u"?U:BigInt64Array,"%BigUint64Array%":typeof BigUint64Array>"u"?U:BigUint64Array,"%Boolean%":Boolean,"%DataView%":typeof DataView>"u"?U:DataView,"%Date%":Date,"%decodeURI%":decodeURI,"%decodeURIComponent%":decodeURIComponent,"%encodeURI%":encodeURI,"%encodeURIComponent%":encodeURIComponent,"%Error%":jl,"%eval%":eval,"%EvalError%":Fl,"%Float16Array%":typeof Float16Array>"u"?U:Float16Array,"%Float32Array%":typeof Float32Array>"u"?U:Float32Array,"%Float64Array%":typeof Float64Array>"u"?U:Float64Array,"%FinalizationRegistry%":typeof FinalizationRegistry>"u"?U:FinalizationRegistry,"%Function%":ws,"%GeneratorFunction%":We,"%Int8Array%":typeof Int8Array>"u"?U:Int8Array,"%Int16Array%":typeof Int16Array>"u"?U:Int16Array,"%Int32Array%":typeof Int32Array>"u"?U:Int32Array,"%isFinite%":isFinite,"%isNaN%":isNaN,"%IteratorPrototype%":He&&J?J(J([][Symbol.iterator]())):U,"%JSON%":typeof JSON=="object"?JSON:U,"%Map%":typeof Map>"u"?U:Map,"%MapIteratorPrototype%":typeof Map>"u"||!He||!J?U:J(new Map()[Symbol.iterator]()),"%Math%":Math,"%Number%":Number,"%Object%":Ll,"%Object.getOwnPropertyDescriptor%":_t,"%parseFloat%":parseFloat,"%parseInt%":parseInt,"%Promise%":typeof Promise>"u"?U:Promise,"%Proxy%":typeof Proxy>"u"?U:Proxy,"%RangeError%":Bl,"%ReferenceError%":Zl,"%Reflect%":typeof Reflect>"u"?U:Reflect,"%RegExp%":RegExp,"%Set%":typeof Set>"u"?U:Set,"%SetIteratorPrototype%":typeof Set>"u"||!He||!J?U:J(new Set()[Symbol.iterator]()),"%SharedArrayBuffer%":typeof SharedArrayBuffer>"u"?U:SharedArrayBuffer,"%String%":String,"%StringIteratorPrototype%":He&&J?J(""[Symbol.iterator]()):U,"%Symbol%":He?Symbol:U,"%SyntaxError%":qe,"%ThrowTypeError%":Ql,"%TypedArray%":rd,"%TypeError%":Ge,"%Uint8Array%":typeof Uint8Array>"u"?U:Uint8Array,"%Uint8ClampedArray%":typeof Uint8ClampedArray>"u"?U:Uint8ClampedArray,"%Uint16Array%":typeof Uint16Array>"u"?U:Uint16Array,"%Uint32Array%":typeof Uint32Array>"u"?U:Uint32Array,"%URIError%":Vl,"%WeakMap%":typeof WeakMap>"u"?U:WeakMap,"%WeakRef%":typeof WeakRef>"u"?U:WeakRef,"%WeakSet%":typeof WeakSet>"u"?U:WeakSet,"%Function.prototype.call%":Pt,"%Function.prototype.apply%":Rs,"%Object.defineProperty%":Yl,"%Object.getPrototypeOf%":ed,"%Math.abs%":Hl,"%Math.floor%":Wl,"%Math.max%":Gl,"%Math.min%":ql,"%Math.pow%":Kl,"%Math.round%":Jl,"%Math.sign%":Xl,"%Reflect.getPrototypeOf%":td};if(J)try{null.error}catch(e){zs=J(J(e)),Ne["%Error.prototype%"]=zs}var zs,nd=o(function e(t){var r;if(t==="%AsyncFunction%")r=un("async function () {}");else if(t==="%GeneratorFunction%")r=un("function* () {}");else if(t==="%AsyncGeneratorFunction%")r=un("async function* () {}");else if(t==="%AsyncGenerator%"){var n=e("%AsyncGeneratorFunction%");n&&(r=n.prototype)}else if(t==="%AsyncIteratorPrototype%"){var i=e("%AsyncGenerator%");i&&J&&(r=J(i.prototype))}return Ne[t]=r,r},"doEval"),Os={__proto__:null,"%ArrayBufferPrototype%":["ArrayBuffer","prototype"],"%ArrayPrototype%":["Array","prototype"],"%ArrayProto_entries%":["Array","prototype","entries"],"%ArrayProto_forEach%":["Array","prototype","forEach"],"%ArrayProto_keys%":["Array","prototype","keys"],"%ArrayProto_values%":["Array","prototype","values"],"%AsyncFunctionPrototype%":["AsyncFunction","prototype"],"%AsyncGenerator%":["AsyncGeneratorFunction","prototype"],"%AsyncGeneratorPrototype%":["AsyncGeneratorFunction","prototype","prototype"],"%BooleanPrototype%":["Boolean","prototype"],"%DataViewPrototype%":["DataView","prototype"],"%DatePrototype%":["Date","prototype"],"%ErrorPrototype%":["Error","prototype"],"%EvalErrorPrototype%":["EvalError","prototype"],"%Float32ArrayPrototype%":["Float32Array","prototype"],"%Float64ArrayPrototype%":["Float64Array","prototype"],"%FunctionPrototype%":["Function","prototype"],"%Generator%":["GeneratorFunction","prototype"],"%GeneratorPrototype%":["GeneratorFunction","prototype","prototype"],"%Int8ArrayPrototype%":["Int8Array","prototype"],"%Int16ArrayPrototype%":["Int16Array","prototype"],"%Int32ArrayPrototype%":["Int32Array","prototype"],"%JSONParse%":["JSON","parse"],"%JSONStringify%":["JSON","stringify"],"%MapPrototype%":["Map","prototype"],"%NumberPrototype%":["Number","prototype"],"%ObjectPrototype%":["Object","prototype"],"%ObjProto_toString%":["Object","prototype","toString"],"%ObjProto_valueOf%":["Object","prototype","valueOf"],"%PromisePrototype%":["Promise","prototype"],"%PromiseProto_then%":["Promise","prototype","then"],"%Promise_all%":["Promise","all"],"%Promise_reject%":["Promise","reject"],"%Promise_resolve%":["Promise","resolve"],"%RangeErrorPrototype%":["RangeError","prototype"],"%ReferenceErrorPrototype%":["ReferenceError","prototype"],"%RegExpPrototype%":["RegExp","prototype"],"%SetPrototype%":["Set","prototype"],"%SharedArrayBufferPrototype%":["SharedArrayBuffer","prototype"],"%StringPrototype%":["String","prototype"],"%SymbolPrototype%":["Symbol","prototype"],"%SyntaxErrorPrototype%":["SyntaxError","prototype"],"%TypedArrayPrototype%":["TypedArray","prototype"],"%TypeErrorPrototype%":["TypeError","prototype"],"%Uint8ArrayPrototype%":["Uint8Array","prototype"],"%Uint8ClampedArrayPrototype%":["Uint8ClampedArray","prototype"],"%Uint16ArrayPrototype%":["Uint16Array","prototype"],"%Uint32ArrayPrototype%":["Uint32Array","prototype"],"%URIErrorPrototype%":["URIError","prototype"],"%WeakMapPrototype%":["WeakMap","prototype"],"%WeakSetPrototype%":["WeakSet","prototype"]},bt=Ve(),or=sn(),od=bt.call(Pt,Array.prototype.concat),id=bt.call(Rs,Array.prototype.splice),ks=bt.call(Pt,String.prototype.replace),ir=bt.call(Pt,String.prototype.slice),ad=bt.call(Pt,RegExp.prototype.exec),sd=/[^%.[\]]+|\[(?:(-?\d+(?:\.\d+)?)|(["'])((?:(?!\2)[^\\]|\\.)*?)\2)\]|(?=(?:\.|\[\])(?:\.|\[\]|%$))/g,ud=/\\(\\)?/g,cd=o(function(t){var r=ir(t,0,1),n=ir(t,-1);if(r==="%"&&n!=="%")throw new qe("invalid intrinsic syntax, expected closing `%`");if(n==="%"&&r!=="%")throw new qe("invalid intrinsic syntax, expected opening `%`");var i=[];return ks(t,sd,function(u,c,p,f){i[i.length]=p?ks(f,ud,"$1"):c||u}),i},"stringToPath"),pd=o(function(t,r){var n=t,i;if(or(Os,n)&&(i=Os[n],n="%"+i[0]+"%"),or(Ne,n)){var u=Ne[n];if(u===We&&(u=nd(n)),typeof u>"u"&&!r)throw new Ge("intrinsic "+t+" exists, but is not available. Please file an issue!");return{alias:i,name:n,value:u}}throw new qe("intrinsic "+t+" does not exist!")},"getBaseIntrinsic");Ns.exports=o(function(t,r){if(typeof t!="string"||t.length===0)throw new Ge("intrinsic name must be a non-empty string");if(arguments.length>1&&typeof r!="boolean")throw new Ge('"allowMissing" argument must be a boolean');if(ad(/^%?[^%]*%?$/,t)===null)throw new qe("`%` may not be present anywhere but at the beginning and end of the intrinsic name");var n=cd(t),i=n.length>0?n[0]:"",u=pd("%"+i+"%",r),c=u.name,p=u.value,f=!1,g=u.alias;g&&(i=g[0],id(n,od([0,1],g)));for(var x=1,b=!0;x<n.length;x+=1){var _=n[x],s=ir(_,0,1),d=ir(_,-1);if((s==='"'||s==="'"||s==="`"||d==='"'||d==="'"||d==="`")&&s!==d)throw new qe("property names with quotes must have matching quotes");if((_==="constructor"||!b)&&(f=!0),i+="."+_,c="%"+i+"%",or(Ne,c))p=Ne[c];else if(p!=null){if(!(_ in p)){if(!r)throw new Ge("base intrinsic for "+t+" exists, but the property is not available.");return}if(_t&&x+1>=n.length){var y=_t(p,_);b=!!y,b&&"get"in y&&!("originalValue"in y.get)?p=y.get:p=p[_]}else b=or(p,_),p=p[_];b&&!f&&(Ne[c]=p)}}return p},"GetIntrinsic")});var Us=E((Dz,Cs)=>{"use strict";var ld=tn();Cs.exports=o(function(){return ld()&&!!Symbol.toStringTag},"hasToStringTagShams")});var js=E((Uz,Ls)=>{"use strict";var dd=Ds(),Ms=dd("%Object.defineProperty%",!0),md=Us()(),fd=sn(),gd=er(),ar=md?Symbol.toStringTag:null;Ls.exports=o(function(t,r){var n=arguments.length>2&&!!arguments[2]&&arguments[2].force,i=arguments.length>2&&!!arguments[2]&&arguments[2].nonConfigurable;if(typeof n<"u"&&typeof n!="boolean"||typeof i<"u"&&typeof i!="boolean")throw new gd("if provided, the `overrideIfSet` and `nonConfigurable` options must be booleans");ar&&(n||!fd(t,ar))&&(Ms?Ms(t,ar,{configurable:!i,enumerable:!1,value:r,writable:!1}):t[ar]=r)},"setToStringTag")});var Bs=E((Lz,Fs)=>{"use strict";var yd=Function.prototype.call,hd=Object.prototype.hasOwnProperty,vd=Ve();Fs.exports=vd.call(yd,hd)});var Vs=E((jz,Zs)=>{"use strict";Zs.exports=function(e,t){return Object.keys(t).forEach(function(r){e[r]=e[r]||t[r]}),e}});var Gs=E((Fz,Ws)=>{"use strict";var mn=Ki(),xd=require("util"),pn=require("path"),_d=require("http"),Pd=require("https"),bd=require("url").parse,Id=require("fs"),Td=require("stream").Stream,Ed=require("crypto"),ln=ea(),$d=ha(),Sd=js(),ze=Bs(),dn=Vs();function Hs(e){return String(e).replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/"/g,"%22")}o(Hs,"escapeHeaderParam");function L(e){if(!(this instanceof L))return new L(e);this._overheadLength=0,this._valueLength=0,this._valuesToMeasure=[],mn.call(this),e=e||{};for(var t in e)this[t]=e[t]}o(L,"FormData");xd.inherits(L,mn);L.LINE_BREAK=`\r
2
+ `;L.DEFAULT_CONTENT_TYPE="application/octet-stream";L.prototype.append=function(e,t,r){r=r||{},typeof r=="string"&&(r={filename:r});var n=mn.prototype.append.bind(this);if((typeof t=="number"||t==null)&&(t=String(t)),Array.isArray(t)){this._error(new Error("Arrays are not supported."));return}var i=this._multiPartHeader(e,t,r),u=this._multiPartFooter();n(i),n(t),n(u),this._trackLength(i,t,r)};L.prototype._trackLength=function(e,t,r){var n=0;r.knownLength!=null?n+=Number(r.knownLength):Buffer.isBuffer(t)?n=t.length:typeof t=="string"&&(n=Buffer.byteLength(t)),this._valueLength+=n,this._overheadLength+=Buffer.byteLength(e)+L.LINE_BREAK.length,!(!t||!t.path&&!(t.readable&&ze(t,"httpVersion"))&&!(t instanceof Td))&&(r.knownLength||this._valuesToMeasure.push(t))};L.prototype._lengthRetriever=function(e,t){ze(e,"fd")?e.end!=null&&e.end!=1/0&&e.start!=null?t(null,e.end+1-(e.start?e.start:0)):Id.stat(e.path,function(r,n){if(r){t(r);return}var i=n.size-(e.start?e.start:0);t(null,i)}):ze(e,"httpVersion")?t(null,Number(e.headers["content-length"])):ze(e,"httpModule")?(e.on("response",function(r){e.pause(),t(null,Number(r.headers["content-length"]))}),e.resume()):t("Unknown stream")};L.prototype._multiPartHeader=function(e,t,r){if(typeof r.header=="string")return r.header;var n=this._getContentDisposition(t,r),i=this._getContentType(t,r),u="",c={"Content-Disposition":["form-data",'name="'+Hs(e)+'"'].concat(n||[]),"Content-Type":[].concat(i||[])};typeof r.header=="object"&&dn(c,r.header);var p;for(var f in c)if(ze(c,f)){if(p=c[f],p==null)continue;Array.isArray(p)||(p=[p]),p.length&&(u+=f+": "+p.join("; ")+L.LINE_BREAK)}return"--"+this.getBoundary()+L.LINE_BREAK+u+L.LINE_BREAK};L.prototype._getContentDisposition=function(e,t){var r;if(typeof t.filepath=="string"?r=pn.normalize(t.filepath).replace(/\\/g,"/"):t.filename||e&&(e.name||e.path)?r=pn.basename(t.filename||e&&(e.name||e.path)):e&&e.readable&&ze(e,"httpVersion")&&(r=pn.basename(e.client._httpMessage.path||"")),r)return'filename="'+Hs(r)+'"'};L.prototype._getContentType=function(e,t){var r=t.contentType;return!r&&e&&e.name&&(r=ln.lookup(e.name)),!r&&e&&e.path&&(r=ln.lookup(e.path)),!r&&e&&e.readable&&ze(e,"httpVersion")&&(r=e.headers["content-type"]),!r&&(t.filepath||t.filename)&&(r=ln.lookup(t.filepath||t.filename)),!r&&e&&typeof e=="object"&&(r=L.DEFAULT_CONTENT_TYPE),r};L.prototype._multiPartFooter=function(){return function(e){var t=L.LINE_BREAK,r=this._streams.length===0;r&&(t+=this._lastBoundary()),e(t)}.bind(this)};L.prototype._lastBoundary=function(){return"--"+this.getBoundary()+"--"+L.LINE_BREAK};L.prototype.getHeaders=function(e){var t,r={"content-type":"multipart/form-data; boundary="+this.getBoundary()};for(t in e)ze(e,t)&&(r[t.toLowerCase()]=e[t]);return r};L.prototype.setBoundary=function(e){if(typeof e!="string")throw new TypeError("FormData boundary must be a string");this._boundary=e};L.prototype.getBoundary=function(){return this._boundary||this._generateBoundary(),this._boundary};L.prototype.getBuffer=function(){for(var e=new Buffer.alloc(0),t=this.getBoundary(),r=0,n=this._streams.length;r<n;r++)typeof this._streams[r]!="function"&&(Buffer.isBuffer(this._streams[r])?e=Buffer.concat([e,this._streams[r]]):e=Buffer.concat([e,Buffer.from(this._streams[r])]),(typeof this._streams[r]!="string"||this._streams[r].substring(2,t.length+2)!==t)&&(e=Buffer.concat([e,Buffer.from(L.LINE_BREAK)])));return Buffer.concat([e,Buffer.from(this._lastBoundary())])};L.prototype._generateBoundary=function(){this._boundary="--------------------------"+Ed.randomBytes(12).toString("hex")};L.prototype.getLengthSync=function(){var e=this._overheadLength+this._valueLength;return this._streams.length&&(e+=this._lastBoundary().length),this.hasKnownLength()||this._error(new Error("Cannot calculate proper length in synchronous way.")),e};L.prototype.hasKnownLength=function(){var e=!0;return this._valuesToMeasure.length&&(e=!1),e};L.prototype.getLength=function(e){var t=this._overheadLength+this._valueLength;if(this._streams.length&&(t+=this._lastBoundary().length),!this._valuesToMeasure.length){process.nextTick(e.bind(this,null,t));return}$d.parallel(this._valuesToMeasure,this._lengthRetriever,function(r,n){if(r){e(r);return}n.forEach(function(i){t+=i}),e(null,t)})};L.prototype.submit=function(e,t){var r,n,i={method:"post"};return typeof e=="string"?(e=bd(e),n=dn({port:e.port,path:e.pathname,host:e.hostname,protocol:e.protocol},i)):(n=dn(e,i),n.port||(n.port=n.protocol==="https:"?443:80)),n.headers=this.getHeaders(e.headers),n.protocol==="https:"?r=Pd.request(n):r=_d.request(n),this.getLength(function(u,c){if(u&&u!=="Unknown stream"){this._error(u);return}if(c&&r.setHeader("Content-Length",c),this.pipe(r),t){var p,f=o(function(g,x){return r.removeListener("error",f),r.removeListener("response",p),t.call(this,g,x)},"callback");p=f.bind(this,null),r.on("error",f),r.on("response",p)}}.bind(this)),r};L.prototype._error=function(e){this.error||(this.error=e,this.pause(),this.emit("error",e))};L.prototype.toString=function(){return"[object FormData]"};Sd(L.prototype,"FormData");Ws.exports=L});var Ld={};vn(Ld,{chatwoot:()=>Md});module.exports=au(Ld);var su=Object.freeze({status:"aborted"});function I(e,t,r){function n(p,f){if(p._zod||Object.defineProperty(p,"_zod",{value:{def:f,constr:c,traits:new Set},enumerable:!1}),p._zod.traits.has(e))return;p._zod.traits.add(e),t(p,f);let g=c.prototype,x=Object.keys(g);for(let b=0;b<x.length;b++){let _=x[b];_ in p||(p[_]=g[_].bind(p))}}o(n,"init");let i=r?.Parent??Object;class u extends i{static{o(this,"Definition")}}Object.defineProperty(u,"name",{value:e});function c(p){var f;let g=r?.Parent?new u:this;n(g,p),(f=g._zod).deferred??(f.deferred=[]);for(let x of g._zod.deferred)x();return g}return o(c,"_"),Object.defineProperty(c,"init",{value:n}),Object.defineProperty(c,Symbol.hasInstance,{value:o(p=>r?.Parent&&p instanceof r.Parent?!0:p?._zod?.traits?.has(e),"value")}),Object.defineProperty(c,"name",{value:e}),c}o(I,"$constructor");var se=class extends Error{static{o(this,"$ZodAsyncError")}constructor(){super("Encountered Promise during synchronous parse. Use .parseAsync() instead.")}},Et=class extends Error{static{o(this,"$ZodEncodeError")}constructor(t){super(`Encountered unidirectional transform during encode: ${t}`),this.name="ZodEncodeError"}},cr={};function le(e){return e&&Object.assign(cr,e),cr}o(le,"config");function lr(e){let t=Object.values(e).filter(n=>typeof n=="number");return Object.entries(e).filter(([n,i])=>t.indexOf(+n)===-1).map(([n,i])=>i)}o(lr,"getEnumValues");function Pn(e,t){return typeof t=="bigint"?t.toString():t}o(Pn,"jsonStringifyReplacer");function St(e){return{get value(){{let r=e();return Object.defineProperty(this,"value",{value:r}),r}throw new Error("cached value already set")}}}o(St,"cached");function bn(e){return e==null}o(bn,"nullish");function At(e){let t=e.startsWith("^")?1:0,r=e.endsWith("$")?e.length-1:e.length;return e.slice(t,r)}o(At,"cleanRegex");var _n=Symbol("evaluating");function q(e,t,r){let n;Object.defineProperty(e,t,{get(){if(n!==_n)return n===void 0&&(n=_n,n=r()),n},set(i){Object.defineProperty(e,t,{value:i})},configurable:!0})}o(q,"defineLazy");var dr="captureStackTrace"in Error?Error.captureStackTrace:(...e)=>{};function Xe(e){return typeof e=="object"&&e!==null&&!Array.isArray(e)}o(Xe,"isObject");var uu=St(()=>{if(typeof navigator<"u"&&navigator?.userAgent?.includes("Cloudflare"))return!1;try{let e=Function;return new e(""),!0}catch{return!1}});function In(e){if(Xe(e)===!1)return!1;let t=e.constructor;if(t===void 0||typeof t!="function")return!0;let r=t.prototype;return!(Xe(r)===!1||Object.prototype.hasOwnProperty.call(r,"isPrototypeOf")===!1)}o(In,"isPlainObject");var Tn=new Set(["string","number","symbol"]);function Ue(e){return e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&")}o(Ue,"escapeRegex");function zt(e,t,r){let n=new e._zod.constr(t??e._zod.def);return(!t||r?.parent)&&(n._zod.parent=e),n}o(zt,"clone");function Z(e){let t=e;if(!t)return{};if(typeof t=="string")return{error:o(()=>t,"error")};if(t?.message!==void 0){if(t?.error!==void 0)throw new Error("Cannot specify both `message` and `error` params");t.error=t.message}return delete t.message,typeof t.error=="string"?{...t,error:o(()=>t.error,"error")}:t}o(Z,"normalizeParams");function En(e){return Object.keys(e).filter(t=>e[t]._zod.optin==="optional"&&e[t]._zod.optout==="optional")}o(En,"optionalKeys");var $n={safeint:[Number.MIN_SAFE_INTEGER,Number.MAX_SAFE_INTEGER],int32:[-2147483648,2147483647],uint32:[0,4294967295],float32:[-34028234663852886e22,34028234663852886e22],float64:[-Number.MAX_VALUE,Number.MAX_VALUE]};function Me(e,t=0){if(e.aborted===!0)return!0;for(let r=t;r<e.issues.length;r++)if(e.issues[r]?.continue!==!0)return!0;return!1}o(Me,"aborted");function _e(e,t){return t.map(r=>{var n;return(n=r).path??(n.path=[]),r.path.unshift(e),r})}o(_e,"prefixIssues");function $t(e){return typeof e=="string"?e:e?.message}o($t,"unwrapMessage");function Pe(e,t,r){let n={...e,path:e.path??[]};if(!e.message){let i=$t(e.inst?._zod.def?.error?.(e))??$t(t?.error?.(e))??$t(r.customError?.(e))??$t(r.localeError?.(e))??"Invalid input";n.message=i}return delete n.inst,delete n.continue,t?.reportInput||delete n.input,n}o(Pe,"finalizeIssue");function Sn(e){return Array.isArray(e)?"array":typeof e=="string"?"string":"unknown"}o(Sn,"getLengthableOrigin");function mr(...e){let[t,r,n]=e;return typeof t=="string"?{message:t,code:"custom",input:r,inst:n}:{...t}}o(mr,"issue");var An=o((e,t)=>{e.name="$ZodError",Object.defineProperty(e,"_zod",{value:e._zod,enumerable:!1}),Object.defineProperty(e,"issues",{value:t,enumerable:!1}),e.message=JSON.stringify(t,Pn,2),Object.defineProperty(e,"toString",{value:o(()=>e.message,"value"),enumerable:!1})},"initializer"),zn=I("$ZodError",An),Ye=I("$ZodError",An,{Parent:Error});var pu=o(e=>(t,r,n,i)=>{let u=n?Object.assign(n,{async:!1}):{async:!1},c=t._zod.run({value:r,issues:[]},u);if(c instanceof Promise)throw new se;if(c.issues.length){let p=new(i?.Err??e)(c.issues.map(f=>Pe(f,u,le())));throw dr(p,i?.callee),p}return c.value},"_parse"),Ot=pu(Ye),lu=o(e=>async(t,r,n,i)=>{let u=n?Object.assign(n,{async:!0}):{async:!0},c=t._zod.run({value:r,issues:[]},u);if(c instanceof Promise&&(c=await c),c.issues.length){let p=new(i?.Err??e)(c.issues.map(f=>Pe(f,u,le())));throw dr(p,i?.callee),p}return c.value},"_parseAsync"),kt=lu(Ye),du=o(e=>(t,r,n)=>{let i=n?{...n,async:!1}:{async:!1},u=t._zod.run({value:r,issues:[]},i);if(u instanceof Promise)throw new se;return u.issues.length?{success:!1,error:new(e??zn)(u.issues.map(c=>Pe(c,i,le())))}:{success:!0,data:u.value}},"_safeParse"),Qe=du(Ye),mu=o(e=>async(t,r,n)=>{let i=n?Object.assign(n,{async:!0}):{async:!0},u=t._zod.run({value:r,issues:[]},i);return u instanceof Promise&&(u=await u),u.issues.length?{success:!1,error:new e(u.issues.map(c=>Pe(c,i,le())))}:{success:!0,data:u.value}},"_safeParseAsync"),et=mu(Ye);var fu="(?:(?:\\d\\d[2468][048]|\\d\\d[13579][26]|\\d\\d0[48]|[02468][048]00|[13579][26]00)-02-29|\\d{4}-(?:(?:0[13578]|1[02])-(?:0[1-9]|[12]\\d|3[01])|(?:0[469]|11)-(?:0[1-9]|[12]\\d|30)|(?:02)-(?:0[1-9]|1\\d|2[0-8])))",gu=new RegExp(`^${fu}$`);var On=o(e=>{let t=e?`[\\s\\S]{${e?.minimum??0},${e?.maximum??""}}`:"[\\s\\S]*";return new RegExp(`^${t}$`)},"string"),kn=/^-?\d+n?$/,wn=/^-?\d+$/,fr=/^-?\d+(?:\.\d+)?$/,Rn=/^(?:true|false)$/i;var be=I("$ZodCheck",(e,t)=>{var r;e._zod??(e._zod={}),e._zod.def=t,(r=e._zod).onattach??(r.onattach=[])}),yu={number:"number",bigint:"bigint",object:"date"};var Nn=I("$ZodCheckGreaterThan",(e,t)=>{be.init(e,t);let r=yu[typeof t.value];e._zod.onattach.push(n=>{let i=n._zod.bag,u=(t.inclusive?i.minimum:i.exclusiveMinimum)??Number.NEGATIVE_INFINITY;t.value>u&&(t.inclusive?i.minimum=t.value:i.exclusiveMinimum=t.value)}),e._zod.check=n=>{(t.inclusive?n.value>=t.value:n.value>t.value)||n.issues.push({origin:r,code:"too_small",minimum:typeof t.value=="object"?t.value.getTime():t.value,input:n.value,inclusive:t.inclusive,inst:e,continue:!t.abort})}});var Dn=I("$ZodCheckNumberFormat",(e,t)=>{be.init(e,t),t.format=t.format||"float64";let r=t.format?.includes("int"),n=r?"int":"number",[i,u]=$n[t.format];e._zod.onattach.push(c=>{let p=c._zod.bag;p.format=t.format,p.minimum=i,p.maximum=u,r&&(p.pattern=wn)}),e._zod.check=c=>{let p=c.value;if(r){if(!Number.isInteger(p)){c.issues.push({expected:n,format:t.format,code:"invalid_type",continue:!1,input:p,inst:e});return}if(!Number.isSafeInteger(p)){p>0?c.issues.push({input:p,code:"too_big",maximum:Number.MAX_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort}):c.issues.push({input:p,code:"too_small",minimum:Number.MIN_SAFE_INTEGER,note:"Integers must be within the safe integer range.",inst:e,origin:n,inclusive:!0,continue:!t.abort});return}}p<i&&c.issues.push({origin:"number",input:p,code:"too_small",minimum:i,inclusive:!0,inst:e,continue:!t.abort}),p>u&&c.issues.push({origin:"number",input:p,code:"too_big",maximum:u,inclusive:!0,inst:e,continue:!t.abort})}});var Cn=I("$ZodCheckMinLength",(e,t)=>{var r;be.init(e,t),(r=e._zod.def).when??(r.when=n=>{let i=n.value;return!bn(i)&&i.length!==void 0}),e._zod.onattach.push(n=>{let i=n._zod.bag.minimum??Number.NEGATIVE_INFINITY;t.minimum>i&&(n._zod.bag.minimum=t.minimum)}),e._zod.check=n=>{let i=n.value;if(i.length>=t.minimum)return;let c=Sn(i);n.issues.push({origin:c,code:"too_small",minimum:t.minimum,inclusive:!0,input:i,inst:e,continue:!t.abort})}});var gr=I("$ZodCheckStringFormat",(e,t)=>{var r,n;be.init(e,t),e._zod.onattach.push(i=>{let u=i._zod.bag;u.format=t.format,t.pattern&&(u.patterns??(u.patterns=new Set),u.patterns.add(t.pattern))}),t.pattern?(r=e._zod).check??(r.check=i=>{t.pattern.lastIndex=0,!t.pattern.test(i.value)&&i.issues.push({origin:"string",code:"invalid_format",format:t.format,input:i.value,...t.pattern?{pattern:t.pattern.toString()}:{},inst:e,continue:!t.abort})}):(n=e._zod).check??(n.check=()=>{})}),Un=I("$ZodCheckRegex",(e,t)=>{gr.init(e,t),e._zod.check=r=>{t.pattern.lastIndex=0,!t.pattern.test(r.value)&&r.issues.push({origin:"string",code:"invalid_format",format:"regex",input:r.value,pattern:t.pattern.toString(),inst:e,continue:!t.abort})}});var Ln={major:4,minor:3,patch:6};var H=I("$ZodType",(e,t)=>{var r;e??(e={}),e._zod.def=t,e._zod.bag=e._zod.bag||{},e._zod.version=Ln;let n=[...e._zod.def.checks??[]];e._zod.traits.has("$ZodCheck")&&n.unshift(e);for(let i of n)for(let u of i._zod.onattach)u(e);if(n.length===0)(r=e._zod).deferred??(r.deferred=[]),e._zod.deferred?.push(()=>{e._zod.run=e._zod.parse});else{let i=o((c,p,f)=>{let g=Me(c),x;for(let b of p){if(b._zod.def.when){if(!b._zod.def.when(c))continue}else if(g)continue;let _=c.issues.length,s=b._zod.check(c);if(s instanceof Promise&&f?.async===!1)throw new se;if(x||s instanceof Promise)x=(x??Promise.resolve()).then(async()=>{await s,c.issues.length!==_&&(g||(g=Me(c,_)))});else{if(c.issues.length===_)continue;g||(g=Me(c,_))}}return x?x.then(()=>c):c},"runChecks"),u=o((c,p,f)=>{if(Me(c))return c.aborted=!0,c;let g=i(p,n,f);if(g instanceof Promise){if(f.async===!1)throw new se;return g.then(x=>e._zod.parse(x,f))}return e._zod.parse(g,f)},"handleCanaryResult");e._zod.run=(c,p)=>{if(p.skipChecks)return e._zod.parse(c,p);if(p.direction==="backward"){let g=e._zod.parse({value:c.value,issues:[]},{...p,skipChecks:!0});return g instanceof Promise?g.then(x=>u(x,c,p)):u(g,c,p)}let f=e._zod.parse(c,p);if(f instanceof Promise){if(p.async===!1)throw new se;return f.then(g=>i(g,n,p))}return i(f,n,p)}}q(e,"~standard",()=>({validate:o(i=>{try{let u=Qe(e,i);return u.success?{value:u.data}:{issues:u.error?.issues}}catch{return et(e,i).then(c=>c.success?{value:c.data}:{issues:c.error?.issues})}},"validate"),vendor:"zod",version:1}))}),Nt=I("$ZodString",(e,t)=>{H.init(e,t),e._zod.pattern=[...e?._zod.bag?.patterns??[]].pop()??On(e._zod.bag),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=String(r.value)}catch{}return typeof r.value=="string"||r.issues.push({expected:"string",code:"invalid_type",input:r.value,inst:e}),r}}),yr=I("$ZodStringFormat",(e,t)=>{gr.init(e,t),Nt.init(e,t)});var Vn=I("$ZodURL",(e,t)=>{yr.init(e,t),e._zod.check=r=>{try{let n=r.value.trim(),i=new URL(n);t.hostname&&(t.hostname.lastIndex=0,t.hostname.test(i.hostname)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid hostname",pattern:t.hostname.source,input:r.value,inst:e,continue:!t.abort})),t.protocol&&(t.protocol.lastIndex=0,t.protocol.test(i.protocol.endsWith(":")?i.protocol.slice(0,-1):i.protocol)||r.issues.push({code:"invalid_format",format:"url",note:"Invalid protocol",pattern:t.protocol.source,input:r.value,inst:e,continue:!t.abort})),t.normalize?r.value=i.href:r.value=n;return}catch{r.issues.push({code:"invalid_format",format:"url",input:r.value,inst:e,continue:!t.abort})}}});var hr=I("$ZodNumber",(e,t)=>{H.init(e,t),e._zod.pattern=e._zod.bag.pattern??fr,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=Number(r.value)}catch{}let i=r.value;if(typeof i=="number"&&!Number.isNaN(i)&&Number.isFinite(i))return r;let u=typeof i=="number"?Number.isNaN(i)?"NaN":Number.isFinite(i)?void 0:"Infinity":void 0;return r.issues.push({expected:"number",code:"invalid_type",input:i,inst:e,...u?{received:u}:{}}),r}}),Hn=I("$ZodNumberFormat",(e,t)=>{Dn.init(e,t),hr.init(e,t)}),vr=I("$ZodBoolean",(e,t)=>{H.init(e,t),e._zod.pattern=Rn,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=!!r.value}catch{}let i=r.value;return typeof i=="boolean"||r.issues.push({expected:"boolean",code:"invalid_type",input:i,inst:e}),r}}),Wn=I("$ZodBigInt",(e,t)=>{H.init(e,t),e._zod.pattern=kn,e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=BigInt(r.value)}catch{}return typeof r.value=="bigint"||r.issues.push({expected:"bigint",code:"invalid_type",input:r.value,inst:e}),r}});var Gn=I("$ZodAny",(e,t)=>{H.init(e,t),e._zod.parse=r=>r}),qn=I("$ZodUnknown",(e,t)=>{H.init(e,t),e._zod.parse=r=>r});var Kn=I("$ZodVoid",(e,t)=>{H.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;return typeof i>"u"||r.issues.push({expected:"void",code:"invalid_type",input:i,inst:e}),r}}),Jn=I("$ZodDate",(e,t)=>{H.init(e,t),e._zod.parse=(r,n)=>{if(t.coerce)try{r.value=new Date(r.value)}catch{}let i=r.value,u=i instanceof Date;return u&&!Number.isNaN(i.getTime())||r.issues.push({expected:"date",code:"invalid_type",input:i,...u?{received:"Invalid Date"}:{},inst:e}),r}});function jn(e,t,r){e.issues.length&&t.issues.push(..._e(r,e.issues)),t.value[r]=e.value}o(jn,"handleArrayResult");var Xn=I("$ZodArray",(e,t)=>{H.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!Array.isArray(i))return r.issues.push({expected:"array",code:"invalid_type",input:i,inst:e}),r;r.value=Array(i.length);let u=[];for(let c=0;c<i.length;c++){let p=i[c],f=t.element._zod.run({value:p,issues:[]},n);f instanceof Promise?u.push(f.then(g=>jn(g,r,c))):jn(f,r,c)}return u.length?Promise.all(u).then(()=>r):r}});function Rt(e,t,r,n,i){if(e.issues.length){if(i&&!(r in n))return;t.issues.push(..._e(r,e.issues))}e.value===void 0?r in n&&(t.value[r]=void 0):t.value[r]=e.value}o(Rt,"handlePropertyResult");function hu(e){let t=Object.keys(e.shape);for(let n of t)if(!e.shape?.[n]?._zod?.traits?.has("$ZodType"))throw new Error(`Invalid element at key "${n}": expected a Zod schema`);let r=En(e.shape);return{...e,keys:t,keySet:new Set(t),numKeys:t.length,optionalKeys:new Set(r)}}o(hu,"normalizeDef");function vu(e,t,r,n,i,u){let c=[],p=i.keySet,f=i.catchall._zod,g=f.def.type,x=f.optout==="optional";for(let b in t){if(p.has(b))continue;if(g==="never"){c.push(b);continue}let _=f.run({value:t[b],issues:[]},n);_ instanceof Promise?e.push(_.then(s=>Rt(s,r,b,t,x))):Rt(_,r,b,t,x)}return c.length&&r.issues.push({code:"unrecognized_keys",keys:c,input:t,inst:u}),e.length?Promise.all(e).then(()=>r):r}o(vu,"handleCatchall");var Yn=I("$ZodObject",(e,t)=>{if(H.init(e,t),!Object.getOwnPropertyDescriptor(t,"shape")?.get){let p=t.shape;Object.defineProperty(t,"shape",{get:o(()=>{let f={...p};return Object.defineProperty(t,"shape",{value:f}),f},"get")})}let n=St(()=>hu(t));q(e._zod,"propValues",()=>{let p=t.shape,f={};for(let g in p){let x=p[g]._zod;if(x.values){f[g]??(f[g]=new Set);for(let b of x.values)f[g].add(b)}}return f});let i=Xe,u=t.catchall,c;e._zod.parse=(p,f)=>{c??(c=n.value);let g=p.value;if(!i(g))return p.issues.push({expected:"object",code:"invalid_type",input:g,inst:e}),p;p.value={};let x=[],b=c.shape;for(let _ of c.keys){let s=b[_],d=s._zod.optout==="optional",y=s._zod.run({value:g[_],issues:[]},f);y instanceof Promise?x.push(y.then(m=>Rt(m,p,_,g,d))):Rt(y,p,_,g,d)}return u?vu(x,g,p,f,n.value,e):x.length?Promise.all(x).then(()=>p):p}});function Fn(e,t,r,n){for(let u of e)if(u.issues.length===0)return t.value=u.value,t;let i=e.filter(u=>!Me(u));return i.length===1?(t.value=i[0].value,i[0]):(t.issues.push({code:"invalid_union",input:t.value,inst:r,errors:e.map(u=>u.issues.map(c=>Pe(c,n,le())))}),t)}o(Fn,"handleUnionResults");var xr=I("$ZodUnion",(e,t)=>{H.init(e,t),q(e._zod,"optin",()=>t.options.some(i=>i._zod.optin==="optional")?"optional":void 0),q(e._zod,"optout",()=>t.options.some(i=>i._zod.optout==="optional")?"optional":void 0),q(e._zod,"values",()=>{if(t.options.every(i=>i._zod.values))return new Set(t.options.flatMap(i=>Array.from(i._zod.values)))}),q(e._zod,"pattern",()=>{if(t.options.every(i=>i._zod.pattern)){let i=t.options.map(u=>u._zod.pattern);return new RegExp(`^(${i.map(u=>At(u.source)).join("|")})$`)}});let r=t.options.length===1,n=t.options[0]._zod.run;e._zod.parse=(i,u)=>{if(r)return n(i,u);let c=!1,p=[];for(let f of t.options){let g=f._zod.run({value:i.value,issues:[]},u);if(g instanceof Promise)p.push(g),c=!0;else{if(g.issues.length===0)return g;p.push(g)}}return c?Promise.all(p).then(f=>Fn(f,i,e,u)):Fn(p,i,e,u)}});var Qn=I("$ZodDiscriminatedUnion",(e,t)=>{t.inclusive=!1,xr.init(e,t);let r=e._zod.parse;q(e._zod,"propValues",()=>{let i={};for(let u of t.options){let c=u._zod.propValues;if(!c||Object.keys(c).length===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(u)}"`);for(let[p,f]of Object.entries(c)){i[p]||(i[p]=new Set);for(let g of f)i[p].add(g)}}return i});let n=St(()=>{let i=t.options,u=new Map;for(let c of i){let p=c._zod.propValues?.[t.discriminator];if(!p||p.size===0)throw new Error(`Invalid discriminated union option at index "${t.options.indexOf(c)}"`);for(let f of p){if(u.has(f))throw new Error(`Duplicate discriminator value "${String(f)}"`);u.set(f,c)}}return u});e._zod.parse=(i,u)=>{let c=i.value;if(!Xe(c))return i.issues.push({code:"invalid_type",expected:"object",input:c,inst:e}),i;let p=n.value.get(c?.[t.discriminator]);return p?p._zod.run(i,u):t.unionFallback?r(i,u):(i.issues.push({code:"invalid_union",errors:[],note:"No matching discriminator",discriminator:t.discriminator,input:c,path:[t.discriminator],inst:e}),i)}});var eo=I("$ZodRecord",(e,t)=>{H.init(e,t),e._zod.parse=(r,n)=>{let i=r.value;if(!In(i))return r.issues.push({expected:"record",code:"invalid_type",input:i,inst:e}),r;let u=[],c=t.keyType._zod.values;if(c){r.value={};let p=new Set;for(let g of c)if(typeof g=="string"||typeof g=="number"||typeof g=="symbol"){p.add(typeof g=="number"?g.toString():g);let x=t.valueType._zod.run({value:i[g],issues:[]},n);x instanceof Promise?u.push(x.then(b=>{b.issues.length&&r.issues.push(..._e(g,b.issues)),r.value[g]=b.value})):(x.issues.length&&r.issues.push(..._e(g,x.issues)),r.value[g]=x.value)}let f;for(let g in i)p.has(g)||(f=f??[],f.push(g));f&&f.length>0&&r.issues.push({code:"unrecognized_keys",input:i,inst:e,keys:f})}else{r.value={};for(let p of Reflect.ownKeys(i)){if(p==="__proto__")continue;let f=t.keyType._zod.run({value:p,issues:[]},n);if(f instanceof Promise)throw new Error("Async schemas not supported in object keys currently");if(typeof p=="string"&&fr.test(p)&&f.issues.length){let b=t.keyType._zod.run({value:Number(p),issues:[]},n);if(b instanceof Promise)throw new Error("Async schemas not supported in object keys currently");b.issues.length===0&&(f=b)}if(f.issues.length){t.mode==="loose"?r.value[p]=i[p]:r.issues.push({code:"invalid_key",origin:"record",issues:f.issues.map(b=>Pe(b,n,le())),input:p,path:[p],inst:e});continue}let x=t.valueType._zod.run({value:i[p],issues:[]},n);x instanceof Promise?u.push(x.then(b=>{b.issues.length&&r.issues.push(..._e(p,b.issues)),r.value[f.value]=b.value})):(x.issues.length&&r.issues.push(..._e(p,x.issues)),r.value[f.value]=x.value)}}return u.length?Promise.all(u).then(()=>r):r}});var to=I("$ZodEnum",(e,t)=>{H.init(e,t);let r=lr(t.entries),n=new Set(r);e._zod.values=n,e._zod.pattern=new RegExp(`^(${r.filter(i=>Tn.has(typeof i)).map(i=>typeof i=="string"?Ue(i):i.toString()).join("|")})$`),e._zod.parse=(i,u)=>{let c=i.value;return n.has(c)||i.issues.push({code:"invalid_value",values:r,input:c,inst:e}),i}}),ro=I("$ZodLiteral",(e,t)=>{if(H.init(e,t),t.values.length===0)throw new Error("Cannot create literal schema with no valid values");let r=new Set(t.values);e._zod.values=r,e._zod.pattern=new RegExp(`^(${t.values.map(n=>typeof n=="string"?Ue(n):n?Ue(n.toString()):String(n)).join("|")})$`),e._zod.parse=(n,i)=>{let u=n.value;return r.has(u)||n.issues.push({code:"invalid_value",values:t.values,input:u,inst:e}),n}});var no=I("$ZodTransform",(e,t)=>{H.init(e,t),e._zod.parse=(r,n)=>{if(n.direction==="backward")throw new Et(e.constructor.name);let i=t.transform(r.value,r);if(n.async)return(i instanceof Promise?i:Promise.resolve(i)).then(c=>(r.value=c,r));if(i instanceof Promise)throw new se;return r.value=i,r}});function Bn(e,t){return e.issues.length&&t===void 0?{issues:[],value:void 0}:e}o(Bn,"handleOptionalResult");var oo=I("$ZodOptional",(e,t)=>{H.init(e,t),e._zod.optin="optional",e._zod.optout="optional",q(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,void 0]):void 0),q(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${At(r.source)})?$`):void 0}),e._zod.parse=(r,n)=>{if(t.innerType._zod.optin==="optional"){let i=t.innerType._zod.run(r,n);return i instanceof Promise?i.then(u=>Bn(u,r.value)):Bn(i,r.value)}return r.value===void 0?r:t.innerType._zod.run(r,n)}});var io=I("$ZodNullable",(e,t)=>{H.init(e,t),q(e._zod,"optin",()=>t.innerType._zod.optin),q(e._zod,"optout",()=>t.innerType._zod.optout),q(e._zod,"pattern",()=>{let r=t.innerType._zod.pattern;return r?new RegExp(`^(${At(r.source)}|null)$`):void 0}),q(e._zod,"values",()=>t.innerType._zod.values?new Set([...t.innerType._zod.values,null]):void 0),e._zod.parse=(r,n)=>r.value===null?r:t.innerType._zod.run(r,n)});var ao=I("$ZodPipe",(e,t)=>{H.init(e,t),q(e._zod,"values",()=>t.in._zod.values),q(e._zod,"optin",()=>t.in._zod.optin),q(e._zod,"optout",()=>t.out._zod.optout),q(e._zod,"propValues",()=>t.in._zod.propValues),e._zod.parse=(r,n)=>{if(n.direction==="backward"){let u=t.out._zod.run(r,n);return u instanceof Promise?u.then(c=>wt(c,t.in,n)):wt(u,t.in,n)}let i=t.in._zod.run(r,n);return i instanceof Promise?i.then(u=>wt(u,t.out,n)):wt(i,t.out,n)}});function wt(e,t,r){return e.issues.length?(e.aborted=!0,e):t._zod.run({value:e.value,issues:e.issues},r)}o(wt,"handlePipeResult");var so=I("$ZodCustom",(e,t)=>{be.init(e,t),H.init(e,t),e._zod.parse=(r,n)=>r,e._zod.check=r=>{let n=r.value,i=t.fn(n);if(i instanceof Promise)return i.then(u=>Zn(u,r,n,e));Zn(i,r,n,e)}});function Zn(e,t,r,n){if(!e){let i={code:"custom",input:r,inst:n,path:[...n._zod.def.path??[]],continue:!n._zod.def.abort};n._zod.def.params&&(i.params=n._zod.def.params),t.issues.push(mr(i))}}o(Zn,"handleRefineResult");var co;var _r=class{static{o(this,"$ZodRegistry")}constructor(){this._map=new WeakMap,this._idmap=new Map}add(t,...r){let n=r[0];return this._map.set(t,n),n&&typeof n=="object"&&"id"in n&&this._idmap.set(n.id,t),this}clear(){return this._map=new WeakMap,this._idmap=new Map,this}remove(t){let r=this._map.get(t);return r&&typeof r=="object"&&"id"in r&&this._idmap.delete(r.id),this._map.delete(t),this}get(t){let r=t._zod.parent;if(r){let n={...this.get(r)??{}};delete n.id;let i={...n,...this._map.get(t)};return Object.keys(i).length?i:void 0}return this._map.get(t)}has(t){return this._map.has(t)}};function po(){return new _r}o(po,"registry");(co=globalThis).__zod_globalRegistry??(co.__zod_globalRegistry=po());var Pr=globalThis.__zod_globalRegistry;function lo(e,t){return new e({type:"string",...Z(t)})}o(lo,"_string");function mo(e,t){return new e({type:"string",coerce:!0,...Z(t)})}o(mo,"_coercedString");function fo(e,t){return new e({type:"string",format:"url",check:"string_format",abort:!1,...Z(t)})}o(fo,"_url");function go(e,t){return new e({type:"number",checks:[],...Z(t)})}o(go,"_number");function yo(e,t){return new e({type:"number",coerce:!0,checks:[],...Z(t)})}o(yo,"_coercedNumber");function ho(e,t){return new e({type:"number",check:"number_format",abort:!1,format:"safeint",...Z(t)})}o(ho,"_int");function vo(e,t){return new e({type:"boolean",...Z(t)})}o(vo,"_boolean");function xo(e,t){return new e({type:"boolean",coerce:!0,...Z(t)})}o(xo,"_coercedBoolean");function _o(e,t){return new e({type:"bigint",coerce:!0,...Z(t)})}o(_o,"_coercedBigint");function Po(e){return new e({type:"any"})}o(Po,"_any");function bo(e){return new e({type:"unknown"})}o(bo,"_unknown");function Io(e,t){return new e({type:"void",...Z(t)})}o(Io,"_void");function To(e,t){return new e({type:"date",coerce:!0,...Z(t)})}o(To,"_coercedDate");function Dt(e,t){return new Nn({check:"greater_than",...Z(t),value:e,inclusive:!0})}o(Dt,"_gte");function ie(e,t){return new Cn({check:"min_length",...Z(t),minimum:e})}o(ie,"_minLength");function Ie(e,t){return new Un({check:"string_format",format:"regex",...Z(t),pattern:e})}o(Ie,"_regex");function Eo(e,t,r){let n=Z(r);return n.abort??(n.abort=!0),new e({type:"custom",check:"custom",fn:t,...n})}o(Eo,"_custom");var K=I("ZodMiniType",(e,t)=>{if(!e._zod)throw new Error("Uninitialized schema in ZodMiniType.");H.init(e,t),e.def=t,e.type=t.type,e.parse=(r,n)=>Ot(e,r,n,{callee:e.parse}),e.safeParse=(r,n)=>Qe(e,r,n),e.parseAsync=async(r,n)=>kt(e,r,n,{callee:e.parseAsync}),e.safeParseAsync=async(r,n)=>et(e,r,n),e.check=(...r)=>e.clone({...t,checks:[...t.checks??[],...r.map(n=>typeof n=="function"?{_zod:{check:n,def:{check:"custom"},onattach:[]}}:n)]},{parent:!0}),e.with=e.check,e.clone=(r,n)=>zt(e,r,n),e.brand=()=>e,e.register=((r,n)=>(r.add(e,n),e)),e.apply=r=>r(e)}),Ut=I("ZodMiniString",(e,t)=>{Nt.init(e,t),K.init(e,t)});function a(e){return lo(Ut,e)}o(a,"string");var $o=I("ZodMiniStringFormat",(e,t)=>{yr.init(e,t),Ut.init(e,t)});var ku=I("ZodMiniURL",(e,t)=>{Vn.init(e,t),$o.init(e,t)});function So(e){return fo(ku,e)}o(So,"url");var Mt=I("ZodMiniNumber",(e,t)=>{hr.init(e,t),K.init(e,t)});function X(e){return go(Mt,e)}o(X,"number");var wu=I("ZodMiniNumberFormat",(e,t)=>{Hn.init(e,t),Mt.init(e,t)});function Ao(e){return ho(wu,e)}o(Ao,"int");var br=I("ZodMiniBoolean",(e,t)=>{vr.init(e,t),K.init(e,t)});function F(e){return vo(br,e)}o(F,"boolean");var zo=I("ZodMiniBigInt",(e,t)=>{Wn.init(e,t),K.init(e,t)});var Ru=I("ZodMiniAny",(e,t)=>{Gn.init(e,t),K.init(e,t)});function rt(){return Po(Ru)}o(rt,"any");var Nu=I("ZodMiniUnknown",(e,t)=>{qn.init(e,t),K.init(e,t)});function O(){return bo(Nu)}o(O,"unknown");var Du=I("ZodMiniVoid",(e,t)=>{Kn.init(e,t),K.init(e,t)});function Oo(e){return Io(Du,e)}o(Oo,"_void");var ko=I("ZodMiniDate",(e,t)=>{Jn.init(e,t),K.init(e,t)});var Cu=I("ZodMiniArray",(e,t)=>{Xn.init(e,t),K.init(e,t)});function R(e,t){return new Cu({type:"array",element:e,...Z(t)})}o(R,"array");var Uu=I("ZodMiniObject",(e,t)=>{Yn.init(e,t),K.init(e,t),q(e,"shape",()=>t.shape)});function l(e,t){let r={type:"object",shape:e??{},...Z(t)};return new Uu(r)}o(l,"object");var Mu=I("ZodMiniUnion",(e,t)=>{xr.init(e,t),K.init(e,t)});function N(e,t){return new Mu({type:"union",options:e,...Z(t)})}o(N,"union");var Lu=I("ZodMiniDiscriminatedUnion",(e,t)=>{Qn.init(e,t),K.init(e,t)});function Te(e,t,r){return new Lu({type:"union",options:t,discriminator:e,...Z(r)})}o(Te,"discriminatedUnion");var ju=I("ZodMiniRecord",(e,t)=>{eo.init(e,t),K.init(e,t)});function k(e,t,r){return new ju({type:"record",keyType:e,valueType:t,...Z(r)})}o(k,"record");var Fu=I("ZodMiniEnum",(e,t)=>{to.init(e,t),K.init(e,t),e.options=Object.values(t.entries)});function C(e,t){let r=Array.isArray(e)?Object.fromEntries(e.map(n=>[n,n])):e;return new Fu({type:"enum",entries:r,...Z(t)})}o(C,"_enum");var Bu=I("ZodMiniLiteral",(e,t)=>{ro.init(e,t),K.init(e,t)});function $(e,t){return new Bu({type:"literal",values:Array.isArray(e)?e:[e],...Z(t)})}o($,"literal");var Zu=I("ZodMiniTransform",(e,t)=>{no.init(e,t),K.init(e,t)});function Ee(e){return new Zu({type:"transform",transform:e})}o(Ee,"transform");var Vu=I("ZodMiniOptional",(e,t)=>{oo.init(e,t),K.init(e,t)});function h(e){return new Vu({type:"optional",innerType:e})}o(h,"optional");var Hu=I("ZodMiniNullable",(e,t)=>{io.init(e,t),K.init(e,t)});function nt(e){return new Hu({type:"nullable",innerType:e})}o(nt,"nullable");var Wu=I("ZodMiniPipe",(e,t)=>{ao.init(e,t),K.init(e,t)});function $e(e,t){return new Wu({type:"pipe",in:e,out:t})}o($e,"pipe");var Gu=I("ZodMiniCustom",(e,t)=>{so.init(e,t),K.init(e,t)});function Lt(e,t){return Eo(Gu,e??(()=>!0),t)}o(Lt,"custom");var ot={};vn(ot,{bigint:()=>Qu,boolean:()=>Yu,date:()=>ec,number:()=>Xu,string:()=>Ju});function Ju(e){return mo(Ut,e)}o(Ju,"string");function Xu(e){return yo(Mt,e)}o(Xu,"number");function Yu(e){return xo(br,e)}o(Yu,"boolean");function Qu(e){return _o(zo,e)}o(Qu,"bigint");function ec(e){return To(ko,e)}o(ec,"date");var Tr=l({retryOnFailure:l({defaultValue:h(F()),hide:h(F())}),continueOnFailure:l({defaultValue:h(F()),hide:h(F())})}),Ir=class{constructor(t,r,n,i,u,c,p,f,g,x,b){this.name=t;this.displayName=r;this.description=n;this.props=i;this.run=u;this.test=c;this.requireAuth=p;this.errorHandlingOptions=f;this.outputSchema=g;this.audience=x;this.aiMetadata=b}static{o(this,"IAction")}},jt=o(e=>new Ir(e.name,e.displayName,e.description,e.props,e.run,e.test??e.run,e.requireAuth??!0,e.errorHandlingOptions??{continueOnFailure:{defaultValue:!1},retryOnFailure:{defaultValue:!1}},e.outputSchema,e.audience,e.aiMetadata),"createAction");var j=l({displayName:a(),description:h(a())}),D=o((e,t)=>l({type:$(t),required:F(),defaultValue:h(rt())}),"TPropertyValue");var ee=l({...j.shape,...D(a(),"SHORT_TEXT").shape}),de=l({...j.shape,...D(a(),"LONG_TEXT").shape});var Ro=l({label:a(),value:O()}),Ft=l({disabled:h(F()),placeholder:h(a()),options:R(Ro)});var te=l({...j.shape,options:Ft,...D(O(),"STATIC_DROPDOWN").shape}),me=l({...j.shape,options:Ft,...D(R(O()),"STATIC_MULTI_SELECT_DROPDOWN").shape});var Er=l({...j.shape,...D(O(),"DROPDOWN").shape,refreshers:R(a())}),it=l({...j.shape,...D(R(O()),"MULTI_SELECT_DROPDOWN").shape,refreshers:R(a())});var fe=l({...j.shape,...D(F(),"CHECKBOX").shape});var ge=l({...j.shape,...D(X(),"NUMBER").shape});var at=l({...j.shape,streaming:h(F()),...D(O(),"FILE").shape});var st=l({...j.shape,...D(a(),"DATE_TIME").shape});var No=k(a(),N([ee,de,te,it,me,fe,ge,at,st])),ut=l({...j.shape,properties:No,...D(R(O()),"ARRAY").shape});var ct=l({...j.shape,...D(N([k(a(),O())]),"JSON").shape});var Do=N([ee,te,ct,ut,me]),rc=k(a(),Do),$r=l({refreshers:R(a()),...j.shape,...D(O(),"DYNAMIC").shape});var Bt=l({...j.shape,...D(Oo(),"MARKDOWN").shape});var pt=(r=>(r.ARCHIVE="ARCHIVE",r.REGISTRY="REGISTRY",r))(pt||{}),Le=(r=>(r.CUSTOM="CUSTOM",r.OFFICIAL="OFFICIAL",r))(Le||{}),lt=(v=>(v.ARTIFICIAL_INTELLIGENCE="ARTIFICIAL_INTELLIGENCE",v.COMMUNICATION="COMMUNICATION",v.COMMERCE="COMMERCE",v.CORE="CORE",v.UNIVERSAL_AI="UNIVERSAL_AI",v.FLOW_CONTROL="FLOW_CONTROL",v.BUSINESS_INTELLIGENCE="BUSINESS_INTELLIGENCE",v.ACCOUNTING="ACCOUNTING",v.PRODUCTIVITY="PRODUCTIVITY",v.CONTENT_AND_FILES="CONTENT_AND_FILES",v.DEVELOPER_TOOLS="DEVELOPER_TOOLS",v.CUSTOMER_SUPPORT="CUSTOMER_SUPPORT",v.FORMS_AND_SURVEYS="FORMS_AND_SURVEYS",v.HUMAN_RESOURCES="HUMAN_RESOURCES",v.PAYMENT_PROCESSING="PAYMENT_PROCESSING",v.MARKETING="MARKETING",v.SALES_AND_CRM="SALES_AND_CRM",v))(lt||{});var dt=(r=>(r.AUTHORIZATION_CODE="authorization_code",r.CLIENT_CREDENTIALS="client_credentials",r))(dt||{}),Sr="both_client_credentials_and_authorization_code";var Se=(i=>(i.POLLING="POLLING",i.WEBHOOK="WEBHOOK",i.APP_WEBHOOK="APP_WEBHOOK",i.MANUAL="MANUAL",i))(Se||{}),mt=(u=>(u.NONE="NONE",u.HEADER_PRESENT="HEADER_PRESENT",u.QUERY_PRESENT="QUERY_PRESENT",u.BODY_PARAM_PRESENT="BODY_PARAM_PRESENT",u.HEAD_REQUEST="HEAD_REQUEST",u))(mt||{}),nc=l({strategy:C(mt),paramName:h(a())}),ft=(r=>(r.SIMULATION="SIMULATION",r.TEST_FUNCTION="TEST_FUNCTION",r))(ft||{});var Zt=(r=>(r.WEBSOCKET="WEBSOCKET",r.NONE="NONE",r))(Zt||{}),Co=l({status:h(X()),body:h(O()),headers:h(k(a(),a()))}),Uo=l({type:$("DELAY"),resumeDateTime:a(),requestIdToReply:h(a()),handlerId:h(a()),streamStepProgress:h(C(Zt))}),Mo=l({type:$("WEBHOOK"),requestId:a(),requestIdToReply:h(a()),response:Co,handlerId:h(a()),streamStepProgress:h(C(Zt))}),oc=N([Uo,Mo]);var ic=l({body:O(),rawBody:h(O()),headers:k(a(),a()),queryParams:k(a(),a())});function re(e){return e==null}o(re,"isNil");function gt(e){return e==null?!0:typeof e=="string"||Array.isArray(e)?e.length===0:typeof e=="object"?Object.keys(e).length===0:!1}o(gt,"isEmpty");function Vt(e,t){if(e==null)throw new Error(`${t} is null or undefined`)}o(Vt,"assertNotNullOrUndefined");var Ar=Ce(require("crypto"),1);var ac=128,ke,je,sc=o(e=>{!ke||ke.length<e?(ke=Buffer.allocUnsafe(e*ac),Ar.default.randomFillSync(ke),je=0):je+e>ke.length&&(Ar.default.randomFillSync(ke),je=0),je+=e},"fillPool"),uc=o(e=>(sc(e|=0),ke.subarray(je-e,je)),"random"),cc=o((e,t,r)=>{let n=(2<<31-Math.clz32(e.length-1|1))-1,i=Math.ceil(1.6*n*t/e.length);return(u=t)=>{let c="";for(;;){let p=r(i),f=i;for(;f--;)if(c+=e[p[f]&n]||"",c.length===u)return c}}},"customRandom"),jo=o((e,t=21)=>cc(e,t,uc),"customAlphabet");var pc="0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",Fo=21,_b=a().check(Ie(new RegExp(`^[0-9a-zA-Z]{${Fo}}$`))),lc=jo(pc,Fo);var Ae=$e(Ee(e=>e instanceof Date?e.toISOString():e),a()),ne={id:a(),created:Ae,updated:Ae},V=o(e=>h(nt(e)),"Nullable");function zr(e){return h(nt(C(e)))}o(zr,"NullableEnum");var Ib=$e(Ee(e=>e==="true"||e===!0?!0:e==="false"||e===!1?!1:void 0),h(F())),Ht=o(e=>$e(Ee(t=>Array.isArray(t)?t:t!==void 0?[t]:void 0),h(R(e))),"OptionalArrayFromQuery");var $b=k(a(),O());var yt=(x=>(x.OPENAI="openai",x.OPENROUTER="openrouter",x.ANTHROPIC="anthropic",x.AZURE="azure",x.GOOGLE="google",x.ACTIVEPIECES="activepieces",x.CLOUDFLARE_GATEWAY="cloudflare-gateway",x.CUSTOM="custom",x.BEDROCK="bedrock",x.MISTRAL="mistral",x))(yt||{});var Mb=a().check(Ie(/^#[0-9A-Fa-f]{6}$/));var jb=l({filename:a(),data:O(),type:$("file"),mimetype:h(a())});var dc=Ce(Zo());var Gb=l({...ne,name:a(),permissions:R(a()),platformId:V(a()),type:a(),userCount:h(X())});var Vo=(n=>(n.AGENT_DECIDE="agent-decide",n.CHOOSE_YOURSELF="choose-yourself",n.LEAVE_EMPTY="leave-empty",n))(Vo||{}),Or=(r=>(r.FILE="FILE",r.TABLE="TABLE",r))(Or||{}),kr=(n=>(n.SSE="sse",n.STREAMABLE_HTTP="streamable-http",n.SIMPLE_HTTP="http",n))(kr||{});var wr=(n=>(n.TEXT="text",n.NUMBER="number",n.BOOLEAN="boolean",n))(wr||{});var Rr=(r=>(r.IN_PROGRESS="in-progress",r.COMPLETED="completed",r))(Rr||{});var mc=l({mode:C(Vo),value:O()}),fc=l({auth:h(a()),fields:k(a(),mc)}),gc=l({pieceName:a(),pieceVersion:a(),actionName:a(),predefinedInput:h(fc)}),yc=l({type:$("PIECE"),toolName:a().check(ie(1)),pieceMetadata:gc}),hc=l({type:$("none")}),vc=l({type:$("access_token"),accessToken:a()}),xc=l({type:$("api_key"),apiKey:a(),apiKeyHeader:a()}),_c=l({type:$("headers"),headers:k(a(),a())}),Pc=Te("type",[hc,vc,xc,_c]),Ho=l({type:$("FLOW"),toolName:a().check(ie(1)),externalFlowId:a(),flowDisplayName:h(a())}),Wo=l({type:$("MCP"),toolName:a().check(ie(1)),serverUrl:So(),protocol:C(kr),auth:Pc}),Go=l({type:$("KNOWLEDGE_BASE"),toolName:a().check(ie(1)),sourceType:C(Or),sourceId:a(),sourceName:a()}),bc=Te("type",[yc,Ho,Wo,Go]),Ic=l({displayName:a(),description:h(a()),type:C(wr)}),qo=l({type:$("MARKDOWN"),markdown:a()}),Fe={type:$("TOOL_CALL"),input:V(k(a(),O())),output:h(O()),toolName:a(),status:C(Rr),toolCallId:a(),startTime:a(),endTime:h(a())},TI=l(Fe),Ko=Te("toolCallType",[l({...Fe,toolCallType:$("PIECE"),pieceName:a(),pieceVersion:a(),actionName:a()}),l({...Fe,toolCallType:$("FLOW"),displayName:a(),externalFlowId:a()}),l({...Fe,toolCallType:$("MCP"),displayName:a(),serverUrl:a()}),l({...Fe,toolCallType:$("KNOWLEDGE_BASE"),displayName:a(),sourceType:a()}),l({...Fe,toolCallType:$("UNKNOWN"),displayName:a()})]),Tc=N([qo,Ko]);var Nr=(r=>(r.IMAGE="image",r.TEXT="text",r))(Nr||{}),ye=l({apiKey:a()}),Ec=ye,$c=l({apiKey:a(),apiKeyHash:a()}),Sc=ye,Ac=ye,zc=ye,Oc=ye,kc=ye,wc=ye,Rc=ye,ei=l({accessKeyId:a().check(ie(1)),secretAccessKey:a().check(ie(1))}),Nc=l({}),Dc=l({}),Cc=l({}),Uc=l({}),Mc=l({}),Lc=l({}),ti=l({modelId:a(),modelName:a(),modelType:C(Nr)}),ri=l({apiKeyHeader:a(),baseUrl:a(),models:R(ti),defaultHeaders:h(k(a(),a()))}),ni=l({accountId:a(),gatewayId:a(),models:R(ti),vertexProject:h(a()),vertexRegion:h(a())}),oi=l({resourceName:a(),apiVersion:$e(Ee(e=>typeof e=="string"&&e.trim().length===0?void 0:e),h(a()))}),ii=l({region:a().check(ie(1))}),jc=N([Ec,zc,Oc,kc,wc,Ac,Sc,$c,ei,Rc]),ai=N([ri,ni,oi,ii,Nc,Cc,Uc,Mc,Dc,Lc]),Fc=l({id:a(),name:a(),type:C(Nr)}),Bc=l({id:a(),name:a(),provider:C(yt),config:ai,enabledForChat:F()}),Zc=l({provider:C(yt),config:ai,auth:jc,platformId:a()});var AI={openai:"openai",anthropic:"anthropic","google-ai-studio":"google","google-vertex-ai":"google"},Jo=["gpt-5.5","gpt-5.4-mini","gpt-5.4-nano","gpt-4.1","gpt-4.1-mini"],Vc=["claude-sonnet-4-6","claude-opus-4-7","claude-haiku-4-5"],Hc=["claude-sonnet-4.6","claude-opus-4.7","claude-haiku-4.5"],Xo=["gemini-2.5-pro","gemini-2.5-flash","gemini-3.1-pro-preview","gemini-3-flash-preview"],Wc=["grok-4.20","grok-4.1-fast"],Gc={openai:Jo,anthropic:Vc,google:Xo,activepieces:[...Hc.map(e=>`anthropic/${e}`),...Jo.map(e=>`openai/${e}`),...Xo.map(e=>`google/${e}`),...Wc.map(e=>`x-ai/${e}`)]};var Yo=128e3,qc={openai:128e3,anthropic:2e5,google:1048576,bedrock:2e5,azure:128e3,openrouter:128e3,activepieces:2e5,mistral:128e3};function Kc({provider:e}){return e?qc[e]??Yo:Yo}o(Kc,"getMaxContextTokens");var Qo={openai:"text-embedding-3-small",google:"text-embedding-004",azure:"text-embedding-3-small",activepieces:"text-embedding-3-small",openrouter:"openai/text-embedding-3-small"},Jc={anthropic:"native",google:"native",openrouter:"plugin",activepieces:"plugin"},Xc=new Set(["anthropic","mistral"]);function ue(e){return{chatModels:Gc[e],maxContextTokens:Kc({provider:e}),defaultEmbeddingModel:Qo[e],supportsEmbedding:Qo[e]!==void 0,supportsImageGeneration:!Xc.has(e),webSearch:Jc[e]}}o(ue,"buildProviderCapabilities");var Yc={openai:ue("openai"),anthropic:ue("anthropic"),openrouter:ue("openrouter"),azure:ue("azure"),google:ue("google"),"cloudflare-gateway":ue("cloudflare-gateway"),custom:ue("custom"),bedrock:ue("bedrock"),mistral:ue("mistral"),activepieces:ue("activepieces")};var Qc=l({base64Url:a(),fileName:a(),extension:h(a())}),ep=l({mimeType:a(),url:a(),fileName:h(a())}),Dr=N([Qc,ep]);var tp=N([l({type:$("file"),value:Dr}),l({type:$("markdown"),value:a(),files:h(R(Dr))})]),rp=l({sessionId:a(),message:a(),files:h(R(a()))});var ui=(r=>(r.ON_NEW_RECORD="ON_NEW_RECORD",r.ON_UPDATE_RECORD="ON_UPDATE_RECORD",r))(ui||{}),ci=(r=>(r.ENABLED="ENABLED",r.DISABLED="DISABLED",r))(ci||{}),Cr=(n=>(n.RECORD_CREATED="RECORD_CREATED",n.RECORD_UPDATED="RECORD_UPDATED",n.RECORD_DELETED="RECORD_DELETED",n))(Cr||{});var np=N([l({...ne,name:a(),externalId:a(),type:$("STATIC_DROPDOWN"),tableId:a(),projectId:a(),data:l({options:R(l({value:a()}))})}),l({...ne,name:a(),externalId:a(),type:N([$("TEXT"),$("NUMBER"),$("DATE")]),tableId:a(),projectId:a()})]),op=l({...ne,name:a(),folderId:V(a()),projectId:a(),externalId:a(),status:zr(ci),trigger:zr(ui)}),ip=l({...ne,tableId:a(),projectId:a(),cells:k(a(),l({updated:a(),created:a(),value:O(),fieldName:a()}))}),ap=l({events:R(C(Cr)),webhookUrl:a(),flowId:a()}),sp=l({fields:R(l({id:a(),name:a()})),rows:R(k(a(),a())),name:a()}),up=l({projectId:a(),limit:h(ot.number()),cursor:h(a()),name:h(a()),externalIds:Ht(a()),folderId:h(a()),folderIds:Ht(a())}),cp=l({records:R(R(l({fieldId:a(),value:li()}))),tableId:a()}),pp=l({cells:h(R(l({fieldId:a(),value:li()}))),tableId:a(),agentUpdate:h(F())}),pi=Te("operator",[we("eq"),we("neq"),we("gt"),we("gte"),we("lt"),we("lte"),we("co"),si("exists"),si("not_exists")]),lp=l({tableId:a(),limit:h(ot.number()),cursor:h(a()),filters:Ht(pi)});function li(){return $e(Ee(e=>e==null?e:String(e)),nt(a()))}o(li,"coerceToString");function we(e){return l({fieldId:a(),operator:$(e),value:a()})}o(we,"valueFilter");function si(e){return l({fieldId:a(),operator:$(e)})}o(si,"existenceFilter");var dp=l({status:h(X()),body:h(O()),headers:h(k(a(),a()))}),mp=l({...ne,deleted:V(Ae),ownerId:a(),displayName:a(),platformId:a(),externalId:V(a())});var di=l({name:a(),description:h(a()),type:a(),required:F()}),fp=l({pieceName:a(),triggerName:a(),input:l({toolName:a(),toolDescription:a(),inputSchema:R(di),returnsResponse:F()})});var mi="^[0-9]+\\.[0-9]+\\.[0-9]+$",GI=new RegExp(mi),yp="^([~^])?[0-9]+\\.[0-9]+\\.[0-9]+$",qI=a().check(Ie(new RegExp(mi))),KI=a().check(Ie(new RegExp(yp))),hp=l({packageType:$("ARCHIVE"),pieceType:C(Le),pieceName:a(),pieceVersion:a(),archiveId:a(),platformId:a()}),fi=l({packageType:$("REGISTRY"),pieceType:$("OFFICIAL"),pieceName:a(),pieceVersion:a()}),gi=l({packageType:$("REGISTRY"),pieceType:$("CUSTOM"),pieceName:a(),pieceVersion:a(),platformId:a()}),JI=N([fi,gi]),XI=N([hp,fi,gi]);var vp=Te("type",[l({type:$("CRON_EXPRESSION"),cronExpression:a(),timezone:a()}),l({type:$("INTERVAL"),intervalMs:Ao().check(Dt(6e4))})]),YI=l({...ne,type:C(Se),projectId:a(),flowId:a(),triggerName:a(),schedule:V(vp),flowVersionId:a(),pieceName:a(),pieceVersion:a(),deleted:V(a()),simulate:F()}),yi=(m=>(m.UNKNOWN="UNKNOWN",m.FLOW_RUN_LOG="FLOW_RUN_LOG",m.FLOW_RUN_LOG_SLICE="FLOW_RUN_LOG_SLICE",m.PACKAGE_ARCHIVE="PACKAGE_ARCHIVE",m.FLOW_STEP_FILE="FLOW_STEP_FILE",m.SAMPLE_DATA="SAMPLE_DATA",m.TRIGGER_PAYLOAD="TRIGGER_PAYLOAD",m.SAMPLE_DATA_INPUT="SAMPLE_DATA_INPUT",m.TRIGGER_EVENT_FILE="TRIGGER_EVENT_FILE",m.PROJECT_RELEASE="PROJECT_RELEASE",m.FLOW_VERSION_BACKUP="FLOW_VERSION_BACKUP",m.PLATFORM_ASSET="PLATFORM_ASSET",m.USER_PROFILE_PICTURE="USER_PROFILE_PICTURE",m.WEBHOOK_PAYLOAD="WEBHOOK_PAYLOAD",m.KNOWLEDGE_BASE="KNOWLEDGE_BASE",m.FLOW_BUNDLE="FLOW_BUNDLE",m))(yi||{}),hi=(r=>(r.NONE="NONE",r.ZSTD="ZSTD",r))(hi||{}),vi=(r=>(r.S3="S3",r.DB="DB",r))(vi||{}),QI=l({...ne,projectId:V(a()),platformId:V(a()),type:C(yi),compression:C(hi),data:h(O()),location:C(vi),size:V(X()),fileName:V(a()),s3Key:V(a()),metadata:V(k(a(),a()))}),xi=(n=>(n.ADMIN="ADMIN",n.MEMBER="MEMBER",n.OPERATOR="OPERATOR",n))(xi||{}),_i=(r=>(r.ACTIVE="ACTIVE",r.INACTIVE="INACTIVE",r))(_i||{}),eT=l({id:a(),email:a(),firstName:a(),status:C(_i),externalId:V(a()),platformId:V(a()),platformRole:C(xi),lastName:a(),created:Ae,updated:Ae,lastActiveDate:V(Ae),imageUrl:V(a())});var Ur=l({...j.shape,...D(k(a(),O()),"OBJECT").shape});var Ti=l({...j.shape,...D(a(),"COLOR").shape});var Mr=N([ee,de,Bt,fe,te,me,Er,it,$r,ge,ut,Ur,ct,st,at,Ti]),B={ShortText(e){return{...e,valueSchema:void 0,type:"SHORT_TEXT"}},Checkbox(e){return{...e,valueSchema:void 0,type:"CHECKBOX"}},LongText(e){return{...e,valueSchema:void 0,type:"LONG_TEXT"}},MarkDown(e){return{displayName:"Markdown",required:!1,description:e.value,type:"MARKDOWN",valueSchema:void 0,variant:e.variant??"INFO"}},Number(e){return{...e,valueSchema:void 0,type:"NUMBER"}},Json(e){return{...e,valueSchema:void 0,type:"JSON"}},Array(e){return{...e,valueSchema:void 0,type:"ARRAY"}},Object(e){return{...e,valueSchema:void 0,type:"OBJECT"}},Dropdown(e){return{...e,valueSchema:void 0,type:"DROPDOWN"}},StaticDropdown(e){return{...e,valueSchema:void 0,type:"STATIC_DROPDOWN"}},MultiSelectDropdown(e){return{...e,valueSchema:void 0,type:"MULTI_SELECT_DROPDOWN"}},DynamicProperties(e){return{...e,valueSchema:void 0,type:"DYNAMIC"}},StaticMultiSelectDropdown(e){return{...e,valueSchema:void 0,type:"STATIC_MULTI_SELECT_DROPDOWN"}},DateTime(e){return{...e,valueSchema:void 0,type:"DATE_TIME"}},File(e){return{...e,valueSchema:void 0,type:"FILE"}},Custom(e){let t=e.code.toString();return{...e,code:t,valueSchema:void 0,type:"CUSTOM"}},Color(e){return{...e,valueSchema:void 0,type:"COLOR"}}};var ce=l({displayName:a(),description:h(a())});var Ei=l({username:a(),password:a()}),Lr=l({...ce.shape,username:l({displayName:a(),description:h(a())}),password:l({displayName:a(),description:h(a())}),...D(Ei,"BASIC_AUTH").shape});var bp=k(a(),N([ee,de,ge,fe,te])),jr=l({...ce.shape,props:bp,...D(O(),"CUSTOM_AUTH").shape});var Re=l({...ce.shape,...D(l({auth:a()}),"SECRET_TEXT").shape});var Ip=k(a(),N([ee,de,Re,ge,fe,te,me,Bt])),$i=l({...ce.shape,props:Ip,...D(O(),"OIDC").shape});var Fr=(r=>(r.HEADER="HEADER",r.BODY="BODY",r))(Fr||{}),Si=N([ee,Re,te]),Ai=k(a(),Si),Tp=l({props:h(k(a(),Si)),authUrl:a(),tokenUrl:a(),scope:R(a()),prompt:h(N([$("none"),$("consent"),$("login"),$("omit")])),pkce:h(F()),pkceMethod:h(N([$("plain"),$("S256")])),authorizationMethod:h(C(Fr)),grantType:h(N([C(dt),$(Sr)])),extra:h(k(a(),a()))}),zi=l({access_token:a(),props:h(Ai),data:k(a(),rt())}),Br=l({...ce.shape,...Tp.shape,...D(zi,"OAUTH2").shape});var Be=N([Lr,jr,$i,Br,Re]),ht="Connection",Gt={SecretText(e){return{...e,valueSchema:void 0,type:"SECRET_TEXT"}},OAuth2(e){return{...e,valueSchema:void 0,type:"OAUTH2",displayName:e.displayName||ht}},BasicAuth(e){return{...e,valueSchema:void 0,type:"BASIC_AUTH",displayName:e.displayName||ht,required:!0}},CustomAuth(e){return{...e,valueSchema:void 0,type:"CUSTOM_AUTH",displayName:e.displayName||ht}},OIDC(e){return{...e,valueSchema:void 0,type:"OIDC",displayName:e.displayName||ht}},None(){}};var wE={OAUTH2:"OAUTH2",CLOUD_OAUTH2:"OAUTH2",PLATFORM_OAUTH2:"OAUTH2",BASIC_AUTH:"BASIC_AUTH",CUSTOM_AUTH:"CUSTOM_AUTH",OIDC:"OIDC",SECRET_TEXT:"SECRET_TEXT",NO_AUTH:void 0};var Ep=l({...j.shape,...D(O(),"CUSTOM").shape,code:a()});var $p=N([Mr,Be]),Zr=k(a(),$p),YE=k(a(),Mr);var Oi=N([l({strategy:$("CRON"),cronExpression:a()}),l({strategy:$("NONE")})]),Ze=class{constructor(t,r,n,i,u,c,p,f,g,x,b,_,s,d,y,m,v,P,M){this.name=t;this.displayName=r;this.description=n;this.requireAuth=i;this.props=u;this.type=c;this.handshakeConfiguration=p;this.onHandshake=f;this.renewConfiguration=g;this.onRenew=x;this.onEnable=b;this.onDisable=_;this.onStart=s;this.run=d;this.test=y;this.sampleData=m;this.testStrategy=v;this.outputSchema=P;this.aiMetadata=M}static{o(this,"ITrigger")}},ki=o(e=>{switch(e.type){case"WEBHOOK":return new Ze(e.name,e.displayName,e.description,e.requireAuth??!0,e.props,e.type,e.handshakeConfiguration??{strategy:"NONE"},e.onHandshake??(async()=>({status:200})),e.renewConfiguration??{strategy:"NONE"},e.onRenew??(async()=>Promise.resolve()),e.onEnable,e.onDisable,e.onStart??(async()=>Promise.resolve()),e.run,e.test??(()=>Promise.resolve([e.sampleData])),e.sampleData,e.test?"TEST_FUNCTION":"SIMULATION",e.outputSchema,e.aiMetadata);case"POLLING":return new Ze(e.name,e.displayName,e.description,e.requireAuth??!0,e.props,e.type,{strategy:"NONE"},async()=>({status:200}),{strategy:"NONE"},(async()=>Promise.resolve()),e.onEnable,e.onDisable,e.onStart??(async()=>Promise.resolve()),e.run,e.test??(()=>Promise.resolve([e.sampleData])),e.sampleData,"TEST_FUNCTION",e.outputSchema,e.aiMetadata);case"MANUAL":return new Ze(e.name,e.displayName,e.description,e.requireAuth??!0,e.props,e.type,{strategy:"NONE"},async()=>({status:200}),{strategy:"NONE"},(async()=>Promise.resolve()),e.onEnable,e.onDisable,e.onStart??(async()=>Promise.resolve()),e.run,e.test??(()=>Promise.resolve([e.sampleData])),e.sampleData,"TEST_FUNCTION",e.outputSchema,e.aiMetadata);case"APP_WEBHOOK":return new Ze(e.name,e.displayName,e.description,e.requireAuth??!0,e.props,e.type,{strategy:"NONE"},async()=>({status:200}),{strategy:"NONE"},(async()=>Promise.resolve()),e.onEnable,e.onDisable,e.onStart??(async()=>Promise.resolve()),e.run,e.test??(()=>Promise.resolve([e.sampleData])),e.sampleData,re(e.sampleData)&&re(e.test)?"SIMULATION":"TEST_FUNCTION",e.outputSchema,e.aiMetadata)}},"createTrigger");var wi="2",qt="0.82.0";var Vr=class{constructor(t,r,n,i,u,c,p,f,g=qt,x,b="",_){this.displayName=t;this.logoUrl=r;this.authors=n;this.events=i;this.categories=p;this.auth=f;this.minimumSupportedRelease=g;this.maximumSupportedRelease=x;this.description=b;this.deprecated=_;this._actions={};this._triggers={};this.getContextInfo=o(()=>({version:wi}),"getContextInfo");(!Sp(g)||Ap(g,qt))&&(this.minimumSupportedRelease=qt),u.forEach(s=>this._actions[s.name]=s),c.forEach(s=>this._triggers[s.name]=s)}static{o(this,"Piece")}metadata(){return{displayName:this.displayName,logoUrl:this.logoUrl,actions:this._actions,triggers:this._triggers,categories:this.categories,description:this.description,authors:this.authors,auth:this.auth,minimumSupportedRelease:this.minimumSupportedRelease,maximumSupportedRelease:this.maximumSupportedRelease,deprecated:this.deprecated,contextInfo:this.getContextInfo?.()}}getAction(t){return this._actions[t]}getTrigger(t){return this._triggers[t]}actions(){return this._actions}triggers(){return this._triggers}},Ri=o(e=>{if(e.auth&&Array.isArray(e.auth)&&!e.auth.every((r,n,i)=>n===i.findIndex(u=>u.type===r.type)))throw new Error("Auth properties must be unique by type");return new Vr(e.displayName,e.logoUrl,e.authors??[],e.events,e.actions,e.triggers,e.categories??[],e.auth,e.minimumSupportedRelease,e.maximumSupportedRelease,e.description,e.deprecated)},"createPiece");function Sp(e){return/^\d+\.\d+\.\d+$/.test(e)}o(Sp,"isValidSimpleSemver");function Ap(e,t){let[r,n,i]=e.split(".").map(Number),[u,c,p]=t.split(".").map(Number);return r!==u?r<u:n!==c?n<c:i<p}o(Ap,"isSemverLessThan");var zp=h(k(a(),k(a(),a()))),Ni=l({id:h(a()),name:a(),displayName:a(),logoUrl:a(),description:a(),authors:R(a()),platformId:h(a()),directoryPath:h(a()),auth:h(N([Be,R(Be)])),version:a(),categories:h(R(C(lt))),minimumSupportedRelease:h(a()),maximumSupportedRelease:h(a()),deprecated:h(F()),i18n:zp}),Op=C(["human","ai","both"]),Di=l({description:h(a()),idempotent:h(F())}),Ci=l({name:a(),displayName:a(),description:a(),props:Zr,requireAuth:F(),errorHandlingOptions:h(Tr),outputSchema:h(Lt()),audience:h(Op),aiMetadata:h(Di)}),Ui=l({name:a(),displayName:a(),description:a(),props:Zr,errorHandlingOptions:h(Tr),type:C(Se),sampleData:O(),handshakeConfiguration:h(Lt()),renewConfiguration:h(Oi),testStrategy:C(ft),outputSchema:h(Lt()),aiMetadata:h(Di)}),kp=l({...Ni.shape,actions:k(a(),Ci),triggers:k(a(),Ui)}),wp=l({...Ni.shape,actions:X(),triggers:X(),suggestedActions:h(R(Ci)),suggestedTriggers:h(R(Ui))}),Mi=l({projectUsage:X(),pieceType:C(Le),packageType:C(pt),platformId:h(a()),archiveId:h(a())}),Y$=l({...kp.shape,...Mi.shape}),Q$=l({...wp.shape,...Mi.shape}),eS=l({name:a(),version:a()});var Rp=Ce(require("path")),Np=Ce(require("fs/promises"));var Bi=require("node:stream");var Kt=class{constructor(t,r){this.baseUrl=t;this.authenticationConverter=r}static{o(this,"BaseHttpClient")}getUrl(t){let r=new URL(`${this.baseUrl}${t.url}`),n=`${r.origin}${r.pathname}`,i=new URLSearchParams;return r.searchParams.forEach((u,c)=>{i.append(c,u)}),{urlWithoutQueryParams:n,queryParams:i}}getHeaders(t){let r={Accept:"application/json"};return t.authentication&&this.populateAuthentication(t.authentication,r),t.body&&(t.headers?.["Content-Type"]==="text/csv"?r["Content-Type"]="text/csv":r["Content-Type"]="application/json"),t.headers&&(r={...r,...t.headers}),r}populateAuthentication(t,r){this.authenticationConverter.convert(t,r)}};var Jt=class{static{o(this,"DelegatingAuthenticationConverter")}constructor(t=new Hr,r=new Wr){this.converters={BEARER_TOKEN:t,BASIC:r}}convert(t,r){return this.converters[t.type].convert(t,r)}},Hr=class{static{o(this,"BearerTokenAuthenticationConverter")}convert(t,r){return r.Authorization=`Bearer ${t.token}`,r}},Wr=class{static{o(this,"BasicTokenAuthenticationConverter")}convert(t,r){let n=`${t.username}:${t.password}`,i=Buffer.from(n).toString("base64");return r.Authorization=`Basic ${i}`,r}};var vt=class extends Error{constructor(r,n){let i=n.status||500,u=Buffer.isBuffer(n.responseBody)?n.responseBody.toString():n.responseBody;super(JSON.stringify({response:{status:i,body:u},request:{body:r}}));this.requestBody=r;this.status=i,this.responseBody=u}static{o(this,"HttpError")}errorMessage(){return{response:{status:this.status,body:this.responseBody},request:{body:this.requestBody}}}get response(){return{status:this.status,body:this.responseBody}}get request(){return{body:this.requestBody}}};function Li({error:e,requestBody:t}){return e instanceof vt?e.errorMessage():{response:{status:0,body:e instanceof Error?e.message:String(e)},request:{body:t}}}o(Li,"toFailsafeOutput");var xt=(c=>(c.GET="GET",c.POST="POST",c.PATCH="PATCH",c.PUT="PUT",c.DELETE="DELETE",c.HEAD="HEAD",c))(xt||{});var Xt=class extends Kt{static{o(this,"FetchHttpClient")}constructor(t="",r=new Jt){super(t,r)}async sendRequest(t,r){process.env.NODE_TLS_REJECT_UNAUTHORIZED="0";let{urlWithoutQueryParams:n,queryParams:i}=this.getUrl(t),u=this.getHeaders(t),c=t.queryParams??{};for(let[M,Q]of Object.entries(c))i.append(M,Q);let p=i.toString(),f=p?`${n}?${p}`:n,g=t.responseType??"json",x=t.followRedirects??!0,b=t.retries??0,{body:_,extraHeaders:s,isStream:d}=Dp(t.method)?Cp(t.body,u):{body:void 0,extraHeaders:{},isStream:!1},y=Mp({...u,...s}),m=await Up(async()=>{let M=new AbortController,Q=t.timeout&&t.timeout>0?setTimeout(()=>M.abort(),t.timeout):void 0;try{let oe={method:t.method.toString(),headers:y,body:_,redirect:x?"follow":"manual",signal:M.signal};return d&&(oe.duplex="half"),r?.dispatcher!==void 0&&(oe.dispatcher=r.dispatcher),await fetch(f,oe)}finally{Q!==void 0&&clearTimeout(Q)}},b),v=x?300:400;if(m.status<200||m.status>=v){let M=await ji(m,g),Q=new vt(t.body,{status:m.status,responseBody:M});throw console.error("[HttpClient#(sanitized error message)] Request failed:",Q),Q}let P=await ji(m,g);return{status:m.status,headers:Lp(m.headers),body:P}}};function Dp(e){return e!=="GET"&&e!=="HEAD"}o(Dp,"acceptsRequestBody");function Cp(e,t){if(Fp(e))return{body:void 0,extraHeaders:{},isStream:!1};if(jp(e)){let n=new Bi.PassThrough;return e.on("error",i=>n.destroy(i)),e.pipe(n),{body:n,extraHeaders:e.getHeaders(),isStream:!0}}return typeof e=="string"||Buffer.isBuffer(e)||e instanceof URLSearchParams||e instanceof ArrayBuffer||typeof FormData<"u"&&e instanceof FormData||typeof Blob<"u"&&e instanceof Blob?{body:e,extraHeaders:{},isStream:!1}:(t["Content-Type"]??t["content-type"]??"").includes("application/x-www-form-urlencoded")?{body:new URLSearchParams(e).toString(),extraHeaders:{},isStream:!1}:{body:JSON.stringify(e),extraHeaders:{},isStream:!1}}o(Cp,"serializeBody");async function ji(e,t){switch(t){case"arraybuffer":return Buffer.from(await e.arrayBuffer());case"blob":return await e.blob();case"text":return await e.text();default:{let r=await e.text();if(r.length===0)return;try{return JSON.parse(r)}catch{return r}}}}o(ji,"parseResponseBody");async function Up(e,t){let r;for(let n=0;n<=t;n++)try{let i=await e();if(i.status>=500&&n<t){await Fi(n);continue}return i}catch(i){if(r=i,n<t){await Fi(n);continue}throw i}throw r}o(Up,"sendWithRetries");function Fi(e){let t=Math.min(1e3*2**e,3e4);return new Promise(r=>setTimeout(r,t))}o(Fi,"backoff");function Mp(e){let t={};for(let[r,n]of Object.entries(e))n!==void 0&&(t[r.toLowerCase()]=Array.isArray(n)?n.join(", "):n);return t}o(Mp,"normalizeHeaders");function Lp(e){let t={};return e.forEach((r,n)=>{t[n]=r}),t}o(Lp,"toHttpHeaders");function jp(e){return typeof e=="object"&&e!==null&&typeof e.getHeaders=="function"&&typeof e.pipe=="function"&&typeof e.on=="function"}o(jp,"isNodeFormData");function Fp(e){return e==null}o(Fp,"isNil");var he=new Xt;var Ad=Ce(require("fs")),qs=Ce(Gs());var zd={"application/json":"json","application/pdf":"pdf","application/xml":"xml","text/xml":"xml","application/zip":"zip","application/gzip":"gz","application/x-tar":"tar","application/octet-stream":"bin","application/msword":"doc","application/vnd.openxmlformats-officedocument.wordprocessingml.document":"docx","application/vnd.ms-excel":"xls","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet":"xlsx","application/vnd.ms-powerpoint":"ppt","application/vnd.openxmlformats-officedocument.presentationml.presentation":"pptx","application/rtf":"rtf","application/javascript":"js","application/x-www-form-urlencoded":"bin","text/plain":"txt","text/html":"html","text/css":"css","text/csv":"csv","text/calendar":"ics","text/markdown":"md","image/png":"png","image/jpeg":"jpeg","image/jpg":"jpg","image/gif":"gif","image/webp":"webp","image/svg+xml":"svg","image/bmp":"bmp","image/tiff":"tiff","image/x-icon":"ico","image/vnd.microsoft.icon":"ico","image/heic":"heic","audio/mpeg":"mp3","audio/mp4":"m4a","audio/wav":"wav","audio/x-wav":"wav","audio/ogg":"ogg","audio/webm":"weba","video/mp4":"mp4","video/mpeg":"mpeg","video/webm":"webm","video/quicktime":"mov","video/x-msvideo":"avi","font/woff":"woff","font/woff2":"woff2","font/ttf":"ttf","font/otf":"otf"};function Od(e){let t=e.split(";")[0].trim().toLowerCase();return zd[t]??""}o(Od,"contentTypeToExtension");var kd=o(({baseUrl:e,relativePath:t})=>{let r=e.endsWith("/")?e:`${e}/`,n=t.startsWith("/")?t.slice(1):t;return`${r}${n}`},"joinBaseUrlWithRelativePath"),wd=o((e,t)=>{let r="https://api.example.com";try{let n=t?e(t):void 0;return(n?.endsWith("/")?n.slice(0,-1):n)??r}catch{return r}},"getBaseUrlForDescription");function Ks({auth:e,baseUrl:t,authMapping:r,description:n,displayName:i,name:u,props:c,extraProps:p,authLocation:f="headers"}){return jt({audience:"human",name:u||"custom_api_call",displayName:i||"Custom API Call",description:n||"Make a custom API call to a specific endpoint",auth:e,requireAuth:!!e,props:{url:B.DynamicProperties({auth:e,displayName:"",required:!0,refreshers:[],props:o(async({auth:g})=>({url:B.ShortText({displayName:"URL",description:`You can either use the full URL or the relative path to the base URL
3
+ i.e ${wd(t,g)}/resource or /resource`,required:!0,defaultValue:g?t(g):"",...c?.url??{}})}),"props")}),method:B.StaticDropdown({displayName:"Method",required:!0,options:{options:Object.values(xt).map(g=>({label:g,value:g}))},...c?.method??{}}),headers:B.Object({displayName:"Headers",description:"Authorization headers are injected automatically from your connection.",required:!0,...c?.headers??{}}),queryParams:B.Object({displayName:"Query Parameters",required:!0,...c?.queryParams??{}}),body_type:B.StaticDropdown({displayName:"Body Type",required:!1,defaultValue:"none",options:{disabled:!1,options:[{label:"None",value:"none"},{label:"JSON",value:"json"},{label:"Form Data",value:"form_data"},{label:"Raw",value:"raw"}]}}),body:B.DynamicProperties({auth:e,displayName:"Body",refreshers:["body_type"],required:!1,props:o(async({body_type:g})=>{if(!g)return{};let x=g,b={};switch(x){case"none":break;case"json":b.data=B.Json({displayName:"JSON Body",required:!0,...c?.body??{}});break;case"raw":b.data=B.LongText({displayName:"Raw Body",required:!0});break;case"form_data":b.data=B.Array({displayName:"Form Data",required:!0,properties:{fieldName:B.ShortText({displayName:"Field Name",required:!0}),fieldType:B.StaticDropdown({displayName:"Field Type",required:!0,options:{disabled:!1,options:[{label:"Text",value:"text"},{label:"File",value:"file"}]}}),textFieldValue:B.LongText({displayName:"Text Field Value",required:!1}),fileFieldValue:B.File({displayName:"File Field Value",required:!1})}});break}return b},"props")}),response_is_binary:B.Checkbox({displayName:"Response is Binary ?",description:"Enable for files like PDFs, images, etc.",required:!1,defaultValue:!1}),failsafe:B.Checkbox({displayName:"No Error on Failure",required:!1,...c?.failsafe??{}}),timeout:B.Number({displayName:"Timeout (in seconds)",required:!1,...c?.timeout??{}}),followRedirects:B.Checkbox({displayName:"Follow redirects",required:!1,defaultValue:!1}),...p},run:o(async g=>{let{method:x,url:b,headers:_,queryParams:s,body:d,body_type:y,failsafe:m,timeout:v,response_is_binary:P,followRedirects:M}=g.propsValue;Vt(x,"Method"),Vt(b,"URL");let Q=re(r)?{}:await r(g.auth,g.propsValue),oe=b.url,Ke=oe.startsWith("http://")||oe.startsWith("https://")?oe:kd({baseUrl:t(g.auth),relativePath:oe}),xe={method:x,url:Ke,headers:{..._??{},...f==="headers"||!re(f)?Q:{}},queryParams:{...f==="queryParams"?Q:{},...s??{}},timeout:v?v*1e3:0,followRedirects:M};if(P&&(xe.responseType="arraybuffer"),d)if(y&&y!=="none"){let pe=d.data;if(y==="form_data"){let eu=pe,Tt=new qs.default;for(let{fieldName:gn,fieldType:yn,textFieldValue:hn,fileFieldValue:ur}of eu)yn==="text"&&!gt(hn)?Tt.append(gn,hn):yn==="file"&&!gt(ur)&&Tt.append(gn,ur.data,{filename:ur?.filename});xe.body=Tt,xe.headers={...xe.headers,...Tt.getHeaders()}}else xe.body=pe}else y||(xe.body=d);try{let pe=await he.sendRequest(xe);return await Rd(g.files,pe.body,pe.status,pe.headers,P)}catch(pe){if(m)return Li({error:pe,requestBody:xe.body});throw pe}},"run")})}o(Ks,"createCustomApiCallAction");var Rd=o(async(e,t,r,n,i)=>{let u;if(i&&Nd(t)){let c=Array.isArray(n?.["content-type"])?n["content-type"][0]:n?.["content-type"],p=Od(c??"")||"txt",f;t instanceof ArrayBuffer?f=Buffer.from(new Uint8Array(t)):Buffer.isBuffer(t)?f=t:f=Buffer.from(t),u=await e.write({fileName:`output.${p}`,data:f})}else u=t;return{status:r,headers:n,body:u}},"handleBinaryResponse"),Nd=o(e=>e instanceof ArrayBuffer||Buffer.isBuffer(e),"isBinaryBody");function It(e,t){let r=(e??"").replace(/\/+$/,"");return{WEBHOOKS:`${r}/api/v1/accounts/${t}/webhooks`,WEBHOOK_BY_ID:o(n=>`${r}/api/v1/accounts/${t}/webhooks/${n}`,"WEBHOOK_BY_ID"),CONVERSATION_MESSAGES:o(n=>`${r}/api/v1/accounts/${t}/conversations/${n}/messages`,"CONVERSATION_MESSAGES"),PROFILE:`${r}/auth/sign_in`}}o(It,"chatwootEndpoints");var ve="api_access_token";function Oe(e){return{baseUrl:e.props.baseUrl??"",accountId:e.props.accountId??0,apiAccessToken:e.props.apiAccessToken??""}}o(Oe,"getChatwootAuth");var Dd=`
4
+ To connect your Chatwoot account:
5
+
6
+ **Chatwoot URL:**
7
+ - For Chatwoot Cloud, use: \`https://app.chatwoot.com\`
8
+ - For self-hosted instances, use your server URL (e.g. \`https://chatwoot.yourcompany.com\`)
9
+
10
+ **API Access Token:**
11
+ 1. Log in to your Chatwoot dashboard.
12
+ 2. Click your avatar in the bottom-left corner and go to **Profile Settings**.
13
+ 3. Scroll down to the **Access Token** section.
14
+ 4. Copy your access token.
15
+
16
+ **Account ID:**
17
+ 1. In your Chatwoot dashboard, the Account ID is visible in the URL: \`/app/accounts/{ACCOUNT_ID}/...\`
18
+ 2. It is a numeric value (e.g. 1, 2, etc.)
19
+
20
+ `,De=Gt.CustomAuth({displayName:"Chatwoot Connection",required:!0,description:Dd,props:{baseUrl:B.ShortText({displayName:"Chatwoot URL",description:"Your Chatwoot instance URL (e.g. https://app.chatwoot.com)",required:!0,defaultValue:"https://app.chatwoot.com"}),apiAccessToken:Gt.SecretText({displayName:"API Access Token",description:"Your user API access token from Profile Settings",required:!0}),accountId:B.Number({displayName:"Account ID",description:"Your numeric account ID (visible in the dashboard URL)",required:!0})}});var Js=3,Cd=1e3;async function Ud(e,t,r,n,i){let c=It(e,t).CONVERSATION_MESSAGES(r),p;for(let f=0;f<Js;f++)try{return(await he.sendRequest({method:"POST",url:c,headers:{[ve]:n,"Content-Type":"application/json"},body:i})).body}catch(g){p=g instanceof Error?g:new Error(String(g));let b=g.response?.status;if(!(b===429||b!==void 0&&b>=500)||f===Js-1)throw p;let s=Cd*Math.pow(2,f);await new Promise(d=>setTimeout(d,s))}throw p??new Error("Send message failed after retries")}o(Ud,"sendWithRetry");var Xs=jt({auth:De,name:"send_message",displayName:"Send Message",description:"Send a message reply to a Chatwoot conversation",audience:"both",aiMetadata:{description:"Posts a new message to an existing Chatwoot conversation, identified by its numeric conversation display ID. Use to reply to a customer or, by enabling the private-note option, to leave an internal note visible only to agents rather than to the contact. Not idempotent \u2014 each call appends another message.",idempotent:!1},props:{conversationId:B.Number({displayName:"Conversation ID",description:"The numeric conversation display ID. Available from the trigger output.",required:!0}),message:B.LongText({displayName:"Message",description:"The text message to send",required:!0}),isPrivate:B.Checkbox({displayName:"Private Note",description:"If checked, sends as a private note visible only to agents (not the contact)",required:!0,defaultValue:!1})},async run(e){let{conversationId:t,message:r,isPrivate:n}=e.propsValue,i=Oe(e.auth),u={content:r,message_type:"outgoing",private:n,content_type:"text"},c=await Ud(i.baseUrl,i.accountId,t,i.apiAccessToken,u);return{success:!0,messageId:c.id,conversationId:c.conversation_id,status:c.status}}});var fn="_chatwoot_webhook_id";function sr(e){return e==null||typeof e!="string"?"":e.trim().replace(/\/+$/,"")}o(sr,"normalizeUrl");function Ys(e){if(Array.isArray(e))return e;if(e&&typeof e=="object"){let t=e;for(let i of["payload","data","webhooks"]){let u=t[i];if(Array.isArray(u))return u}let r=t.payload;if(r&&typeof r=="object"){let u=r.webhooks;if(Array.isArray(u))return u}let n=t.data;if(n&&typeof n=="object"){let u=n.webhooks;if(Array.isArray(u))return u}}return[]}o(Ys,"toWebhookList");var Qs=ki({auth:De,name:"new_message",displayName:"New Incoming Message",description:"Triggers when a contact sends a new message in a Chatwoot conversation",aiMetadata:{description:"Fires when a contact sends a new inbound message in a Chatwoot conversation. Only incoming, non-empty messages are emitted (outgoing agent replies and private notes are filtered out), representing a fresh customer message awaiting a response."},type:"WEBHOOK",props:{},sampleData:{messageId:42,content:"Hello, I need help with my order",messageType:"incoming",conversationId:7,contactId:15,contactName:"Jane Doe",accountId:1,createdAt:"2024-06-15 10:30:00 UTC"},async onEnable(e){let t=Oe(e.auth),r=It(t.baseUrl,t.accountId),n=e.webhookUrl,i;try{let u=await he.sendRequest({method:"GET",url:r.WEBHOOKS,headers:{[ve]:t.apiAccessToken}}),c=Ys(u.body),p=sr(n),f=c.find(g=>sr(g.url)===p);f?i=f.id:i=(await he.sendRequest({method:"POST",url:r.WEBHOOKS,headers:{[ve]:t.apiAccessToken,"Content-Type":"application/json"},body:{url:n,subscriptions:["message_created"]}})).body.payload.webhook.id}catch(u){let c=u?.response?.status,p=u?.response?.body;if(c===422&&p&&typeof p=="object"&&"message"in p&&p.message?.includes("already been taken")){let f=await he.sendRequest({method:"GET",url:r.WEBHOOKS,headers:{[ve]:t.apiAccessToken}}),g=Ys(f.body),x=sr(n),b=g.find(_=>sr(_.url)===x);if(b?.id)i=b.id;else throw u}else throw u}await e.store.put(fn,{webhookId:i})},async onDisable(e){let t=Oe(e.auth),r=It(t.baseUrl,t.accountId),n=await e.store.get(fn);if(n?.webhookId){try{await he.sendRequest({method:"DELETE",url:r.WEBHOOK_BY_ID(n.webhookId),headers:{[ve]:t.apiAccessToken}})}catch(i){console.error("[Chatwoot] Error deleting webhook:",i)}await e.store.delete(fn)}},async run(e){let t=e.payload?.body,r=t&&typeof t=="object"&&"payload"in t?t.payload:t;if(!r||typeof r!="object")return[];if(r.event!=="message_created")return[];if(r.message_type!=="incoming")return[];let u=r.content;if(u==null||String(u).trim().length===0)return[];let c=r.conversation,p=r.contact,f=r.sender,g=r.account,x=0;if(c!=null&&typeof c=="object"){if("display_id"in c){let P=c.display_id;x=P!=null&&Number(P)||0}else if("id"in c){let P=c.id;x=P!=null&&Number(P)||0}}let b=p||f,_=b!=null&&typeof b=="object"&&"id"in b&&Number(b.id)||0,s=b!=null&&typeof b=="object"&&"name"in b?String(b.name):"Unknown",d=g!=null&&typeof g=="object"&&"id"in g&&Number(g.id)||0,y=typeof r.id=="number"?r.id:Number(r.id)||0,m=r.created_at!=null?String(r.created_at):"";return[{messageId:y,content:String(u).trim(),messageType:"incoming",conversationId:x,contactId:_,contactName:s,accountId:d,createdAt:m}]}});var Md=Ri({displayName:"Chatwoot",description:"Receive and reply to customer messages with Chatwoot",auth:De,minimumSupportedRelease:"0.30.0",logoUrl:"https://cdn.activepieces.com/pieces/chatwoot.png",authors:["AhmadTash"],actions:[Xs,Ks({auth:De,baseUrl:o(e=>Oe(e).baseUrl,"baseUrl"),authMapping:o(async e=>{let t=Oe(e);return{[ve]:t.apiAccessToken}},"authMapping")})],triggers:[Qs]});0&&(module.exports={chatwoot});
21
+ /*! Bundled license information:
22
+
23
+ mime-types/index.js:
24
+ (*!
25
+ * mime-types
26
+ * Copyright(c) 2014 Jonathan Ong
27
+ * Copyright(c) 2015 Douglas Christopher Wilson
28
+ * MIT Licensed
29
+ *)
30
+ */
package/src/index.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export declare const chatwoot: import("@activepieces/pieces-framework").Piece<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
- apiAccessToken: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
- accountId: import("@activepieces/pieces-framework").NumberProperty<true>;
5
- }>>;
6
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAQA,eAAO,MAAM,QAAQ;;;;GAwBnB,CAAC"}
package/src/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;AAAA,qEAA6D;AAC7D,6DAAyD;AACzD,4DAAwD;AACxD,qCAA0C;AAC1C,+DAAwE;AACxE,8CAAqD;AACrD,sDAA8D;AAEjD,QAAA,QAAQ,GAAG,IAAA,8BAAW,EAAC;IAClC,WAAW,EAAE,UAAU;IACvB,WAAW,EAAE,sDAAsD;IACnE,IAAI,EAAE,mBAAY;IAClB,uBAAuB,EAAE,QAAQ;IACjC,OAAO,EACL,kDAAkD;IACpD,OAAO,EAAE,CAAC,WAAW,CAAC;IACtB,OAAO,EAAE,CAAC,0BAAW;QACnB,IAAA,yCAAyB,EAAC;YACxB,IAAI,EAAC,mBAAY;YACjB,OAAO,EAAE,CAAC,IAAI,EAAE,EAAE;gBAChB,MAAM,SAAS,GAAG,IAAA,uBAAe,EAAC,IAAK,CAAC,CAAC;gBACzC,OAAO,SAAS,CAAC,OAAO,CAAC;YAC3B,CAAC;YACD,WAAW,EAAE,CAAO,IAAI,EAAE,EAAE;gBAC1B,MAAM,SAAS,GAAG,IAAA,uBAAe,EAAC,IAAK,CAAC,CAAC;gBACzC,OAAO;oBACL,CAAC,gCAAoB,CAAC,EAAE,SAAS,CAAC,cAAc;iBACjD,CAAC;YACJ,CAAC,CAAA;SACF,CAAC;KACH;IACD,QAAQ,EAAE,CAAC,wBAAU,CAAC;CACvB,CAAC,CAAC"}
@@ -1,10 +0,0 @@
1
- export declare const sendMessage: import("@activepieces/pieces-framework").IAction<import("@activepieces/pieces-framework").CustomAuthProperty<{
2
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
- apiAccessToken: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
- accountId: import("@activepieces/pieces-framework").NumberProperty<true>;
5
- }>, {
6
- conversationId: import("@activepieces/pieces-framework").NumberProperty<true>;
7
- message: import("@activepieces/pieces-framework").LongTextProperty<true>;
8
- isPrivate: import("@activepieces/pieces-framework").CheckboxProperty<true>;
9
- }>;
10
- //# sourceMappingURL=send-message.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-message.d.ts","sourceRoot":"","sources":["../../../../src/lib/actions/send-message.ts"],"names":[],"mappings":"AA4DA,eAAO,MAAM,WAAW;;;;;;;;EAyDtB,CAAC"}
@@ -1,95 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.sendMessage = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const pieces_common_1 = require("@activepieces/pieces-common");
7
- const constants_1 = require("../common/constants");
8
- const types_1 = require("../common/types");
9
- const auth_1 = require("../auth");
10
- const MAX_RETRIES = 3;
11
- const INITIAL_BACKOFF_MS = 1000;
12
- function sendWithRetry(baseUrl, accountId, conversationId, token, body) {
13
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
14
- var _a;
15
- const endpoints = (0, constants_1.chatwootEndpoints)(baseUrl, accountId);
16
- const url = endpoints.CONVERSATION_MESSAGES(conversationId);
17
- let lastError;
18
- for (let attempt = 0; attempt < MAX_RETRIES; attempt++) {
19
- try {
20
- const response = yield pieces_common_1.httpClient.sendRequest({
21
- method: pieces_common_1.HttpMethod.POST,
22
- url,
23
- headers: {
24
- [constants_1.CHATWOOT_AUTH_HEADER]: token,
25
- 'Content-Type': 'application/json',
26
- },
27
- body,
28
- });
29
- return response.body;
30
- }
31
- catch (error) {
32
- lastError = error instanceof Error ? error : new Error(String(error));
33
- const errorAny = error;
34
- const statusCode = (_a = errorAny.response) === null || _a === void 0 ? void 0 : _a.status;
35
- const isRetryable = statusCode === 429 ||
36
- (statusCode !== undefined && statusCode >= 500);
37
- if (!isRetryable || attempt === MAX_RETRIES - 1) {
38
- throw lastError;
39
- }
40
- const backoffMs = INITIAL_BACKOFF_MS * Math.pow(2, attempt);
41
- yield new Promise((resolve) => setTimeout(resolve, backoffMs));
42
- }
43
- }
44
- throw lastError !== null && lastError !== void 0 ? lastError : new Error('Send message failed after retries');
45
- });
46
- }
47
- exports.sendMessage = (0, pieces_framework_1.createAction)({
48
- auth: auth_1.chatwootAuth,
49
- name: 'send_message',
50
- displayName: 'Send Message',
51
- description: 'Send a message reply to a Chatwoot conversation',
52
- audience: 'both',
53
- aiMetadata: {
54
- description: 'Posts a new message to an existing Chatwoot conversation, identified by its numeric conversation display ID. Use to reply to a customer or, by enabling the private-note option, to leave an internal note visible only to agents rather than to the contact. Not idempotent — each call appends another message.',
55
- idempotent: false,
56
- },
57
- props: {
58
- conversationId: pieces_framework_1.Property.Number({
59
- displayName: 'Conversation ID',
60
- description: 'The numeric conversation display ID. Available from the trigger output.',
61
- required: true,
62
- }),
63
- message: pieces_framework_1.Property.LongText({
64
- displayName: 'Message',
65
- description: 'The text message to send',
66
- required: true,
67
- }),
68
- isPrivate: pieces_framework_1.Property.Checkbox({
69
- displayName: 'Private Note',
70
- description: 'If checked, sends as a private note visible only to agents (not the contact)',
71
- required: true,
72
- defaultValue: false,
73
- }),
74
- },
75
- run(context) {
76
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
77
- const { conversationId, message, isPrivate } = context.propsValue;
78
- const authValue = (0, types_1.getChatwootAuth)(context.auth);
79
- const body = {
80
- content: message,
81
- message_type: 'outgoing',
82
- private: isPrivate,
83
- content_type: 'text',
84
- };
85
- const result = yield sendWithRetry(authValue.baseUrl, authValue.accountId, conversationId, authValue.apiAccessToken, body);
86
- return {
87
- success: true,
88
- messageId: result.id,
89
- conversationId: result.conversation_id,
90
- status: result.status,
91
- };
92
- });
93
- },
94
- });
95
- //# sourceMappingURL=send-message.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"send-message.js","sourceRoot":"","sources":["../../../../src/lib/actions/send-message.ts"],"names":[],"mappings":";;;;AAAA,qEAAwE;AACxE,+DAAqE;AACrE,mDAA8E;AAC9E,2CAGyB;AACzB,kCAAuC;AAEvC,MAAM,WAAW,GAAG,CAAC,CAAC;AACtB,MAAM,kBAAkB,GAAG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AY,EAAE,MAAM;aACrB,CAAC;YAEF,MAAM,MAAM,GAAG,MAAM,aAAa,CAChC,SAAS,CAAC,OAAO,EACjB,SAAS,CAAC,SAAS,EACnB,cAAc,EACd,SAAS,CAAC,cAAc,EACxB,IAAI,CACL,CAAC;YAEF,OAAO;gBACL,OAAO,EAAE,IAAI;gBACb,SAAS,EAAE,MAAM,CAAC,EAAE;gBACpB,cAAc,EAAE,MAAM,CAAC,eAAe;gBACtC,MAAM,EAAE,MAAM,CAAC,MAAM;aACtB,CAAC;QACJ,CAAC;KAAA;CACF,CAAC,CAAC"}
package/src/lib/auth.d.ts DELETED
@@ -1,6 +0,0 @@
1
- export declare const chatwootAuth: import("@activepieces/pieces-framework").CustomAuthProperty<{
2
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
3
- apiAccessToken: import("@activepieces/pieces-framework").SecretTextProperty<true>;
4
- accountId: import("@activepieces/pieces-framework").NumberProperty<true>;
5
- }>;
6
- //# sourceMappingURL=auth.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.d.ts","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":"AAqBA,eAAO,MAAM,YAAY;;;;EAwBvB,CAAC"}
package/src/lib/auth.js DELETED
@@ -1,46 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.chatwootAuth = void 0;
4
- const pieces_framework_1 = require("@activepieces/pieces-framework");
5
- const authDesc = `
6
- To connect your Chatwoot account:
7
-
8
- **Chatwoot URL:**
9
- - For Chatwoot Cloud, use: \`https://app.chatwoot.com\`
10
- - For self-hosted instances, use your server URL (e.g. \`https://chatwoot.yourcompany.com\`)
11
-
12
- **API Access Token:**
13
- 1. Log in to your Chatwoot dashboard.
14
- 2. Click your avatar in the bottom-left corner and go to **Profile Settings**.
15
- 3. Scroll down to the **Access Token** section.
16
- 4. Copy your access token.
17
-
18
- **Account ID:**
19
- 1. In your Chatwoot dashboard, the Account ID is visible in the URL: \`/app/accounts/{ACCOUNT_ID}/...\`
20
- 2. It is a numeric value (e.g. 1, 2, etc.)
21
-
22
- `;
23
- exports.chatwootAuth = pieces_framework_1.PieceAuth.CustomAuth({
24
- displayName: 'Chatwoot Connection',
25
- required: true,
26
- description: authDesc,
27
- props: {
28
- baseUrl: pieces_framework_1.Property.ShortText({
29
- displayName: 'Chatwoot URL',
30
- description: 'Your Chatwoot instance URL (e.g. https://app.chatwoot.com)',
31
- required: true,
32
- defaultValue: 'https://app.chatwoot.com',
33
- }),
34
- apiAccessToken: pieces_framework_1.PieceAuth.SecretText({
35
- displayName: 'API Access Token',
36
- description: 'Your user API access token from Profile Settings',
37
- required: true,
38
- }),
39
- accountId: pieces_framework_1.Property.Number({
40
- displayName: 'Account ID',
41
- description: 'Your numeric account ID (visible in the dashboard URL)',
42
- required: true,
43
- }),
44
- },
45
- });
46
- //# sourceMappingURL=auth.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth.js","sourceRoot":"","sources":["../../../src/lib/auth.ts"],"names":[],"mappings":";;;AAAA,qEAAqE;AAErE,MAAM,QAAQ,GAAG;;;;;;;;;;;;;;;;;CAiBhB,CAAC;AAEW,QAAA,YAAY,GAAG,4BAAS,CAAC,UAAU,CAAC;IAC/C,WAAW,EAAE,qBAAqB;IAClC,QAAQ,EAAE,IAAI;IACd,WAAW,EAAE,QAAQ;IACrB,KAAK,EAAE;QACL,OAAO,EAAE,2BAAQ,CAAC,SAAS,CAAC;YAC1B,WAAW,EAAE,cAAc;YAC3B,WAAW,EACT,4DAA4D;YAC9D,QAAQ,EAAE,IAAI;YACd,YAAY,EAAE,0BAA0B;SACzC,CAAC;QACF,cAAc,EAAE,4BAAS,CAAC,UAAU,CAAC;YACnC,WAAW,EAAE,kBAAkB;YAC/B,WAAW,EAAE,kDAAkD;YAC/D,QAAQ,EAAE,IAAI;SACf,CAAC;QACF,SAAS,EAAE,2BAAQ,CAAC,MAAM,CAAC;YACzB,WAAW,EAAE,YAAY;YACzB,WAAW,EACT,wDAAwD;YAC1D,QAAQ,EAAE,IAAI;SACf,CAAC;KACH;CACF,CAAC,CAAC"}
@@ -1,9 +0,0 @@
1
- export declare const CHATWOOT_DEFAULT_BASE_URL = "https://app.chatwoot.com";
2
- export declare function chatwootEndpoints(baseUrl: string, accountId: number): {
3
- readonly WEBHOOKS: `${string}/api/v1/accounts/${number}/webhooks`;
4
- readonly WEBHOOK_BY_ID: (webhookId: number) => string;
5
- readonly CONVERSATION_MESSAGES: (conversationId: number) => string;
6
- readonly PROFILE: `${string}/auth/sign_in`;
7
- };
8
- export declare const CHATWOOT_AUTH_HEADER = "api_access_token";
9
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,yBAAyB,6BAA6B,CAAC;AAEpE,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM;;wCAIrC,MAAM;qDAEO,MAAM;;EAIjD;AAED,eAAO,MAAM,oBAAoB,qBAAqB,CAAC"}
@@ -1,16 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.CHATWOOT_AUTH_HEADER = exports.CHATWOOT_DEFAULT_BASE_URL = void 0;
4
- exports.chatwootEndpoints = chatwootEndpoints;
5
- exports.CHATWOOT_DEFAULT_BASE_URL = 'https://app.chatwoot.com';
6
- function chatwootEndpoints(baseUrl, accountId) {
7
- const base = (baseUrl !== null && baseUrl !== void 0 ? baseUrl : '').replace(/\/+$/, '');
8
- return {
9
- WEBHOOKS: `${base}/api/v1/accounts/${accountId}/webhooks`,
10
- WEBHOOK_BY_ID: (webhookId) => `${base}/api/v1/accounts/${accountId}/webhooks/${webhookId}`,
11
- CONVERSATION_MESSAGES: (conversationId) => `${base}/api/v1/accounts/${accountId}/conversations/${conversationId}/messages`,
12
- PROFILE: `${base}/auth/sign_in`,
13
- };
14
- }
15
- exports.CHATWOOT_AUTH_HEADER = 'api_access_token';
16
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../../src/lib/common/constants.ts"],"names":[],"mappings":";;;AAEA,8CAUC;AAZY,QAAA,yBAAyB,GAAG,0BAA0B,CAAC;AAEpE,SAAgB,iBAAiB,CAAC,OAAe,EAAE,SAAiB;IAClE,MAAM,IAAI,GAAG,CAAC,OAAO,aAAP,OAAO,cAAP,OAAO,GAAI,EAAE,CAAC,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACjD,OAAO;QACL,QAAQ,EAAE,GAAG,IAAI,oBAAoB,SAAS,WAAW;QACzD,aAAa,EAAE,CAAC,SAAiB,EAAE,EAAE,CACnC,GAAG,IAAI,oBAAoB,SAAS,aAAa,SAAS,EAAE;QAC9D,qBAAqB,EAAE,CAAC,cAAsB,EAAE,EAAE,CAChD,GAAG,IAAI,oBAAoB,SAAS,kBAAkB,cAAc,WAAW;QACjF,OAAO,EAAE,GAAG,IAAI,eAAe;KACvB,CAAC;AACb,CAAC;AAEY,QAAA,oBAAoB,GAAG,kBAAkB,CAAC"}
@@ -1,95 +0,0 @@
1
- import { AppConnectionValueForAuthProperty } from '@activepieces/pieces-framework';
2
- import { chatwootAuth } from '../auth';
3
- export interface ChatwootWebhookSender {
4
- id: number;
5
- name: string;
6
- email?: string;
7
- phone_number?: string;
8
- type?: string;
9
- }
10
- export interface ChatwootWebhookContact {
11
- id: number;
12
- name: string;
13
- email?: string;
14
- phone_number?: string;
15
- }
16
- export interface ChatwootWebhookConversation {
17
- display_id: number;
18
- additional_attributes?: Record<string, unknown>;
19
- }
20
- export interface ChatwootWebhookAccount {
21
- id: number;
22
- name: string;
23
- }
24
- export type ChatwootMessageType = 'incoming' | 'outgoing' | 'template';
25
- export interface ChatwootWebhookPayload {
26
- event: string;
27
- id: number;
28
- content: string;
29
- created_at: string;
30
- message_type: ChatwootMessageType;
31
- content_type: string;
32
- content_attributes: Record<string, unknown>;
33
- source_id: string;
34
- sender: ChatwootWebhookSender;
35
- contact: ChatwootWebhookContact;
36
- conversation: ChatwootWebhookConversation;
37
- account: ChatwootWebhookAccount;
38
- }
39
- export interface ChatwootParsedMessage {
40
- messageId: number;
41
- content: string;
42
- messageType: ChatwootMessageType;
43
- conversationId: number;
44
- contactId: number;
45
- contactName: string;
46
- accountId: number;
47
- createdAt: string;
48
- }
49
- export interface ChatwootCreateWebhookRequest {
50
- url: string;
51
- subscriptions: string[];
52
- }
53
- export interface ChatwootWebhookResponse {
54
- payload: {
55
- webhook: {
56
- id: number;
57
- };
58
- };
59
- }
60
- /** Single webhook in list response (GET /webhooks) */
61
- export interface ChatwootWebhookListItem {
62
- id: number;
63
- url: string;
64
- subscriptions?: string[];
65
- account_id?: number;
66
- }
67
- export interface ChatwootSendMessageRequest {
68
- content: string;
69
- message_type: 'outgoing';
70
- private: boolean;
71
- content_type: 'text';
72
- }
73
- export interface ChatwootSendMessageResponse {
74
- id: number;
75
- content: string;
76
- account_id: number;
77
- inbox_id: number;
78
- conversation_id: number;
79
- message_type: number;
80
- created_at: number;
81
- updated_at: number;
82
- private: boolean;
83
- status: string;
84
- content_type: string;
85
- sender_type: string;
86
- sender_id: number;
87
- }
88
- export interface ChatwootAuthProps {
89
- baseUrl: string;
90
- apiAccessToken: string;
91
- accountId: number;
92
- }
93
- /** Normalize auth from either V0 (props only) or V1 (connection value with type + props) */
94
- export declare function getChatwootAuth(auth: AppConnectionValueForAuthProperty<typeof chatwootAuth>): ChatwootAuthProps;
95
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/lib/common/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iCAAiC,EAAE,MAAM,gCAAgC,CAAC;AACnF,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;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;AAC5F,wBAAgB,eAAe,CAAC,IAAI,EAAE,iCAAiC,CAAC,OAAO,YAAY,CAAC,GAAG,iBAAiB,CAM/G"}
@@ -1,13 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.getChatwootAuth = getChatwootAuth;
4
- /** Normalize auth from either V0 (props only) or V1 (connection value with type + props) */
5
- function getChatwootAuth(auth) {
6
- var _a, _b, _c;
7
- return {
8
- baseUrl: (_a = auth.props.baseUrl) !== null && _a !== void 0 ? _a : '',
9
- accountId: (_b = auth.props.accountId) !== null && _b !== void 0 ? _b : 0,
10
- apiAccessToken: (_c = auth.props.apiAccessToken) !== null && _c !== void 0 ? _c : '',
11
- };
12
- }
13
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/lib/common/types.ts"],"names":[],"mappings":";;AA2GA,0CAMC;AAPD,4FAA4F;AAC5F,SAAgB,eAAe,CAAC,IAA4D;;IAC1F,OAAO;QACL,OAAO,EAAE,MAAA,IAAI,CAAC,KAAK,CAAC,OAAO,mCAAI,EAAE;QACjC,SAAS,EAAE,MAAA,IAAI,CAAC,KAAK,CAAC,SAAS,mCAAI,CAAC;QACpC,cAAc,EAAE,MAAA,IAAI,CAAC,KAAK,CAAC,cAAc,mCAAI,EAAE;KAChD,CAAC;AACJ,CAAC"}
@@ -1,19 +0,0 @@
1
- import { TriggerStrategy } from '@activepieces/pieces-framework';
2
- export declare const newMessage: import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.WEBHOOK, import("@activepieces/pieces-framework").CustomAuthProperty<{
3
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
4
- apiAccessToken: import("@activepieces/pieces-framework").SecretTextProperty<true>;
5
- accountId: import("@activepieces/pieces-framework").NumberProperty<true>;
6
- }>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.POLLING, import("@activepieces/pieces-framework").CustomAuthProperty<{
7
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
8
- apiAccessToken: import("@activepieces/pieces-framework").SecretTextProperty<true>;
9
- accountId: import("@activepieces/pieces-framework").NumberProperty<true>;
10
- }>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.MANUAL, import("@activepieces/pieces-framework").CustomAuthProperty<{
11
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
12
- apiAccessToken: import("@activepieces/pieces-framework").SecretTextProperty<true>;
13
- accountId: import("@activepieces/pieces-framework").NumberProperty<true>;
14
- }>, {}> | import("@activepieces/pieces-framework").ITrigger<TriggerStrategy.APP_WEBHOOK, import("@activepieces/pieces-framework").CustomAuthProperty<{
15
- baseUrl: import("@activepieces/pieces-framework").ShortTextProperty<true>;
16
- apiAccessToken: import("@activepieces/pieces-framework").SecretTextProperty<true>;
17
- accountId: import("@activepieces/pieces-framework").NumberProperty<true>;
18
- }>, {}>;
19
- //# sourceMappingURL=new-message.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-message.d.ts","sourceRoot":"","sources":["../../../../src/lib/triggers/new-message.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,eAAe,EAAE,MAAM,gCAAgC,CAAC;AA4ChF,eAAO,MAAM,UAAU;;;;;;;;;;;;;;;;OA8LrB,CAAC"}
@@ -1,220 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.newMessage = void 0;
4
- const tslib_1 = require("tslib");
5
- const pieces_framework_1 = require("@activepieces/pieces-framework");
6
- const pieces_common_1 = require("@activepieces/pieces-common");
7
- const constants_1 = require("../common/constants");
8
- const types_1 = require("../common/types");
9
- const auth_1 = require("../auth");
10
- const WEBHOOK_STORE_KEY = '_chatwoot_webhook_id';
11
- function normalizeUrl(u) {
12
- if (u == null || typeof u !== 'string')
13
- return '';
14
- return u.trim().replace(/\/+$/, '');
15
- }
16
- function toWebhookList(raw) {
17
- if (Array.isArray(raw))
18
- return raw;
19
- if (raw && typeof raw === 'object') {
20
- const o = raw;
21
- // Top-level array keys
22
- for (const key of ['payload', 'data', 'webhooks']) {
23
- const v = o[key];
24
- if (Array.isArray(v))
25
- return v;
26
- }
27
- // Chatwoot returns { payload: { webhooks: [...] } }
28
- const payload = o['payload'];
29
- if (payload && typeof payload === 'object') {
30
- const p = payload;
31
- const w = p['webhooks'];
32
- if (Array.isArray(w))
33
- return w;
34
- }
35
- const data = o['data'];
36
- if (data && typeof data === 'object') {
37
- const d = data;
38
- const w = d['webhooks'];
39
- if (Array.isArray(w))
40
- return w;
41
- }
42
- }
43
- return [];
44
- }
45
- exports.newMessage = (0, pieces_framework_1.createTrigger)({
46
- auth: auth_1.chatwootAuth,
47
- name: 'new_message',
48
- displayName: 'New Incoming Message',
49
- description: 'Triggers when a contact sends a new message in a Chatwoot conversation',
50
- aiMetadata: {
51
- description: 'Fires when a contact sends a new inbound message in a Chatwoot conversation. Only incoming, non-empty messages are emitted (outgoing agent replies and private notes are filtered out), representing a fresh customer message awaiting a response.',
52
- },
53
- type: pieces_framework_1.TriggerStrategy.WEBHOOK,
54
- props: {},
55
- sampleData: {
56
- messageId: 42,
57
- content: 'Hello, I need help with my order',
58
- messageType: 'incoming',
59
- conversationId: 7,
60
- contactId: 15,
61
- contactName: 'Jane Doe',
62
- accountId: 1,
63
- createdAt: '2024-06-15 10:30:00 UTC',
64
- },
65
- onEnable(context) {
66
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
67
- var _a, _b, _c;
68
- const authValue = (0, types_1.getChatwootAuth)(context.auth);
69
- const endpoints = (0, constants_1.chatwootEndpoints)(authValue.baseUrl, authValue.accountId);
70
- const webhookUrl = context.webhookUrl;
71
- // List existing webhooks and reuse if this URL is already registered (avoids 422 "Url has already been taken")
72
- let webhookId;
73
- try {
74
- const listRes = yield pieces_common_1.httpClient.sendRequest({
75
- method: pieces_common_1.HttpMethod.GET,
76
- url: endpoints.WEBHOOKS,
77
- headers: {
78
- [constants_1.CHATWOOT_AUTH_HEADER]: authValue.apiAccessToken,
79
- },
80
- });
81
- const list = toWebhookList(listRes.body);
82
- const targetUrl = normalizeUrl(webhookUrl);
83
- const existing = list.find((w) => normalizeUrl(w.url) === targetUrl);
84
- if (existing) {
85
- webhookId = existing.id;
86
- }
87
- else {
88
- const createRes = yield pieces_common_1.httpClient.sendRequest({
89
- method: pieces_common_1.HttpMethod.POST,
90
- url: endpoints.WEBHOOKS,
91
- headers: {
92
- [constants_1.CHATWOOT_AUTH_HEADER]: authValue.apiAccessToken,
93
- 'Content-Type': 'application/json',
94
- },
95
- body: {
96
- url: webhookUrl,
97
- subscriptions: ['message_created'],
98
- },
99
- });
100
- webhookId = createRes.body.payload.webhook.id;
101
- }
102
- }
103
- catch (err) {
104
- const status = (_a = err === null || err === void 0 ? void 0 : err.response) === null || _a === void 0 ? void 0 : _a.status;
105
- const body = (_b = err === null || err === void 0 ? void 0 : err.response) === null || _b === void 0 ? void 0 : _b.body;
106
- if (status === 422 && body && typeof body === 'object' && 'message' in body && ((_c = body.message) === null || _c === void 0 ? void 0 : _c.includes('already been taken'))) {
107
- // List might have failed or returned different shape; try listing again with generic type
108
- const listRes = yield pieces_common_1.httpClient.sendRequest({
109
- method: pieces_common_1.HttpMethod.GET,
110
- url: endpoints.WEBHOOKS,
111
- headers: { [constants_1.CHATWOOT_AUTH_HEADER]: authValue.apiAccessToken },
112
- });
113
- const list = toWebhookList(listRes.body);
114
- const targetUrl = normalizeUrl(webhookUrl);
115
- const existing = list.find((w) => normalizeUrl(w.url) === targetUrl);
116
- if (existing === null || existing === void 0 ? void 0 : existing.id) {
117
- webhookId = existing.id;
118
- }
119
- else {
120
- throw err;
121
- }
122
- }
123
- else {
124
- throw err;
125
- }
126
- }
127
- yield context.store.put(WEBHOOK_STORE_KEY, { webhookId });
128
- });
129
- },
130
- onDisable(context) {
131
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
132
- const authValue = (0, types_1.getChatwootAuth)(context.auth);
133
- const endpoints = (0, constants_1.chatwootEndpoints)(authValue.baseUrl, authValue.accountId);
134
- const stored = yield context.store.get(WEBHOOK_STORE_KEY);
135
- if (!(stored === null || stored === void 0 ? void 0 : stored.webhookId)) {
136
- return;
137
- }
138
- try {
139
- yield pieces_common_1.httpClient.sendRequest({
140
- method: pieces_common_1.HttpMethod.DELETE,
141
- url: endpoints.WEBHOOK_BY_ID(stored.webhookId),
142
- headers: {
143
- [constants_1.CHATWOOT_AUTH_HEADER]: authValue.apiAccessToken,
144
- },
145
- });
146
- }
147
- catch (error) {
148
- console.error('[Chatwoot] Error deleting webhook:', error);
149
- }
150
- yield context.store.delete(WEBHOOK_STORE_KEY);
151
- });
152
- },
153
- run(context) {
154
- return tslib_1.__awaiter(this, void 0, void 0, function* () {
155
- var _a;
156
- // Engine passes TriggerPayload: { body, headers, queryParams }. Chatwoot POST body may be raw or wrapped in .payload
157
- const rawBody = (_a = context.payload) === null || _a === void 0 ? void 0 : _a.body;
158
- const payload = (rawBody && typeof rawBody === 'object' && 'payload' in rawBody)
159
- ? rawBody['payload']
160
- : rawBody;
161
- if (!payload || typeof payload !== 'object') {
162
- return [];
163
- }
164
- const event = payload['event'];
165
- if (event !== 'message_created') {
166
- return [];
167
- }
168
- const messageType = payload['message_type'];
169
- if (messageType !== 'incoming') {
170
- return [];
171
- }
172
- const content = payload['content'];
173
- if (content == null || String(content).trim().length === 0) {
174
- return [];
175
- }
176
- const conversation = payload['conversation'];
177
- const contact = payload['contact'];
178
- const sender = payload['sender'];
179
- const account = payload['account'];
180
- // Chatwoot sends conversation.id (not display_id) in webhook payloads
181
- // Try display_id first (for API compatibility), then fall back to id
182
- let conversationId = 0;
183
- if (conversation != null && typeof conversation === 'object') {
184
- if ('display_id' in conversation) {
185
- const displayId = conversation['display_id'];
186
- conversationId = displayId != null ? Number(displayId) || 0 : 0;
187
- }
188
- else if ('id' in conversation) {
189
- const id = conversation['id'];
190
- conversationId = id != null ? Number(id) || 0 : 0;
191
- }
192
- }
193
- // Contact info may be in 'contact' or 'sender' field
194
- const contactObj = contact || sender;
195
- const contactId = contactObj != null && typeof contactObj === 'object' && 'id' in contactObj
196
- ? Number(contactObj['id']) || 0
197
- : 0;
198
- const contactName = contactObj != null && typeof contactObj === 'object' && 'name' in contactObj
199
- ? String(contactObj['name'])
200
- : 'Unknown';
201
- const accountId = account != null && typeof account === 'object' && 'id' in account
202
- ? Number(account['id']) || 0
203
- : 0;
204
- const messageId = typeof payload['id'] === 'number' ? payload['id'] : Number(payload['id']) || 0;
205
- const createdAt = payload['created_at'] != null ? String(payload['created_at']) : '';
206
- const parsed = {
207
- messageId,
208
- content: String(content).trim(),
209
- messageType: 'incoming',
210
- conversationId,
211
- contactId,
212
- contactName,
213
- accountId,
214
- createdAt,
215
- };
216
- return [parsed];
217
- });
218
- },
219
- });
220
- //# sourceMappingURL=new-message.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"new-message.js","sourceRoot":"","sources":["../../../../src/lib/triggers/new-message.ts"],"names":[],"mappings":";;;;AAAA,qEAAgF;AAChF,+DAAqE;AACrE,mDAA8E;AAC9E,2CAKyB;AACzB,kCAAuC;AAEvC,MAAM,iBAAiB,GAAG,sBAAsB,CAAC;AAEjD,SAAS,YAAY,CAAC,CAAqB;IACzC,IAAI,CAAC,IAAI,IAAI,IAAI,OAAO,CAAC,KAAK,QAAQ;QAAE,OAAO,EAAE,CAAC;IAClD,OAAO,CAAC,CAAC,IAAI,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;AACtC,CAAC;AAED,SAAS,aAAa,CAAC,GAAY;IACjC,IAAI,KAAK,CAAC,OAAO,CAAC,GAAG,CAAC;QAAE,OAAO,GAAG,CAAC;IACnC,IAAI,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACnC,MAAM,CAAC,GAAG,GAA8B,CAAC;QACzC,uBAAuB;QACvB,KAAK,MAAM,GAAG,IAAI,CAAC,SAAS,EAAE,MAAM,EAA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