text: (()=>{"use strict";var e={109:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.prototype.hasOwnProperty.call(e,n))r(t,e,n);o(t,e);return t};var s=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){o(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});t.toChatworkMessage=t.postMessage=t.extractUsers=void 0;const u=i(n(186));const a=i(n(211));const c=i(n(191));function parseInput(){const e=+u.getInput("roomid");const t=u.getInput("token");const n=JSON.parse(u.getInput("mapping"));const r=JSON.parse(u.getInput("context"));const o=u.getInput("ignoreBody")==="true";return{roomId:e,token:t,mapping:n,context:r,ignoreBody:o}}function extractUsers(e){const t=[];const n=[...e];let r=0;while(r<n.length){const o=n[r++];if(o!=="@")continue;if(r<n.length){const o=n[r];if(!isAlphaNumeric(o))continue;const i=[];i.push(o);while(++r<n.length){const t=n[r];const o=t==="-";const s=t==="/";if(!(o||s||isAlphaNumeric(t)))break;const u=r+1<e.length?isAlphaNumeric(e[r+1]):false;if(o&&!u)break;if(s&&(!u||i.includes("/")))break;i.push(t)}const s=i.join("");if(!t.includes(s))t.push(s)}}return t}t.extractUsers=extractUsers;function isAlphaNumeric(e){return/^[a-z0-9]+$/i.test(e)}function toChatworkUsers(e,t){return e.map((e=>t[e])).filter((e=>e!=null))}function postMessage(e,t){return new Promise(((n,r)=>{const o={hostname:"api.chatwork.com",port:443,path:`/v2/rooms/${e.roomId}/messages`,method:"POST",headers:{"X-ChatWorkToken":e.token,"Content-Type":"application/x-www-form-urlencoded"}};const i=a.request(o,(e=>{if(e.statusCode!==200){r(new Error(`status code error. status code: ${e.statusCode}`))}e.setEncoding("utf8");let t="";e.on("data",(e=>t+=e));e.on("end",(()=>{try{n(JSON.parse(t))}catch(e){r(e)}}))}));i.on("error",r);i.write(`body=${c.escape(t)}`,(e=>{if(e!=null)r(e)}));i.end()}))}t.postMessage=postMessage;function toChatworkMessage(e,t,n){var r,o,i,s,u,a;const c=e.event.issue||e.event.pull_request;const d=c===null||c===void 0?void 0:c.title;const f=(o=(r=e.event.comment)===null||r===void 0?void 0:r.html_url)!==null&&o!==void 0?o:c===null||c===void 0?void 0:c.html_url;const l=(u=(s=(i=e.event.comment)===null||i===void 0?void 0:i.body)!==null&&s!==void 0?s:c===null||c===void 0?void 0:c.body)!==null&&u!==void 0?u:"";let p=extractUsers(l);if(e.event_name!=="issue_comment"){p=p.concat(c.assignees.concat((a=c.requested_reviewers)!==null&&a!==void 0?a:[]).map((e=>e.login))).filter(((e,t,n)=>n.indexOf(e)===t))}const m=toChatworkUsers(p,t);let g="";if(m.length>0)g+=`${m.join("\n")}\n`;g+=`from: @${e.actor}\ntitle: ${d}\nurl: ${f}\n`;if(!n)g+=`\n${l}`;return g}t.toChatworkMessage=toChatworkMessage;function run(){return s(this,void 0,void 0,(function*(){try{const e=parseInput();u.debug(`event_name: ${e.context.event_name}`);u.debug(`event.action: ${JSON.stringify(e.context.event.action)}`);const t=toChatworkMessage(e.context,e.mapping,e.ignoreBody);u.debug(`message body: ${t}`);const n=yield postMessage(e,t);u.debug(`response: ${n}`);u.setOutput("messageId",n.message_id)}catch(e){u.setFailed(e.message)}}))}run()},351:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);o(t,e);return t};Object.defineProperty(t,"__esModule",{value:true});t.issue=t.issueCommand=void 0;const s=i(n(87));const u=n(278);function issueCommand(e,t,n){const r=new Command(e,t,n);process.stdout.write(r.toString()+s.EOL)}t.issueCommand=issueCommand;function issue(e,t=""){issueCommand(e,{},t)}t.issue=issue;const a="::";class Command{constructor(e,t,n){if(!e){e="missing.command"}this.command=e;this.properties=t;this.message=n}toString(){let e=a+this.command;if(this.properties&&Object.keys(this.properties).length>0){e+=" ";let t=true;for(const n in this.properties){if(this.properties.hasOwnProperty(n)){const r=this.properties[n];if(r){if(t){t=false}else{e+=","}e+=`${n}=${escapeProperty(r)}`}}}}e+=`${a}${escapeData(this.message)}`;return e}}function escapeData(e){return u.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A")}function escapeProperty(e){return u.toCommandValue(e).replace(/%/g,"%25").replace(/\r/g,"%0D").replace(/\n/g,"%0A").replace(/:/g,"%3A").replace(/,/g,"%2C")}},186:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);o(t,e);return t};var s=this&&this.__awaiter||function(e,t,n,r){function adopt(e){return e instanceof n?e:new n((function(t){t(e)}))}return new(n||(n=Promise))((function(n,o){function fulfilled(e){try{step(r.next(e))}catch(e){o(e)}}function rejected(e){try{step(r["throw"](e))}catch(e){o(e)}}function step(e){e.done?n(e.value):adopt(e.value).then(fulfilled,rejected)}step((r=r.apply(e,t||[])).next())}))};Object.defineProperty(t,"__esModule",{value:true});t.getState=t.saveState=t.group=t.endGroup=t.startGroup=t.info=t.warning=t.error=t.debug=t.isDebug=t.setFailed=t.setCommandEcho=t.setOutput=t.getBooleanInput=t.getMultilineInput=t.getInput=t.addPath=t.setSecret=t.exportVariable=t.ExitCode=void 0;const u=n(351);const a=n(717);const c=n(278);const d=i(n(87));const f=i(n(622));var l;(function(e){e[e["Success"]=0]="Success";e[e["Failure"]=1]="Failure"})(l=t.ExitCode||(t.ExitCode={}));function exportVariable(e,t){const n=c.toCommandValue(t);process.env[e]=n;const r=process.env["GITHUB_ENV"]||"";if(r){const t="_GitHubActionsFileCommandDelimeter_";const r=`${e}<<${t}${d.EOL}${n}${d.EOL}${t}`;a.issueCommand("ENV",r)}else{u.issueCommand("set-env",{name:e},n)}}t.exportVariable=exportVariable;function setSecret(e){u.issueCommand("add-mask",{},e)}t.setSecret=setSecret;function addPath(e){const t=process.env["GITHUB_PATH"]||"";if(t){a.issueCommand("PATH",e)}else{u.issueCommand("add-path",{},e)}process.env["PATH"]=`${e}${f.delimiter}${process.env["PATH"]}`}t.addPath=addPath;function getInput(e,t){const n=process.env[`INPUT_${e.replace(/ /g,"_").toUpperCase()}`]||"";if(t&&t.required&&!n){throw new Error(`Input required and not supplied: ${e}`)}if(t&&t.trimWhitespace===false){return n}return n.trim()}t.getInput=getInput;function getMultilineInput(e,t){const n=getInput(e,t).split("\n").filter((e=>e!==""));return n}t.getMultilineInput=getMultilineInput;function getBooleanInput(e,t){const n=["true","True","TRUE"];const r=["false","False","FALSE"];const o=getInput(e,t);if(n.includes(o))return true;if(r.includes(o))return false;throw new TypeError(`Input does not meet YAML 1.2 "Core Schema" specification: ${e}\n`+`Support boolean input list: \`true | True | TRUE | false | False | FALSE\``)}t.getBooleanInput=getBooleanInput;function setOutput(e,t){process.stdout.write(d.EOL);u.issueCommand("set-output",{name:e},t)}t.setOutput=setOutput;function setCommandEcho(e){u.issue("echo",e?"on":"off")}t.setCommandEcho=setCommandEcho;function setFailed(e){process.exitCode=l.Failure;error(e)}t.setFailed=setFailed;function isDebug(){return process.env["RUNNER_DEBUG"]==="1"}t.isDebug=isDebug;function debug(e){u.issueCommand("debug",{},e)}t.debug=debug;function error(e){u.issue("error",e instanceof Error?e.toString():e)}t.error=error;function warning(e){u.issue("warning",e instanceof Error?e.toString():e)}t.warning=warning;function info(e){process.stdout.write(e+d.EOL)}t.info=info;function startGroup(e){u.issue("group",e)}t.startGroup=startGroup;function endGroup(){u.issue("endgroup")}t.endGroup=endGroup;function group(e,t){return s(this,void 0,void 0,(function*(){startGroup(e);let n;try{n=yield t()}finally{endGroup()}return n}))}t.group=group;function saveState(e,t){u.issueCommand("save-state",{name:e},t)}t.saveState=saveState;function getState(e){return process.env[`STATE_${e}`]||""}t.getState=getState},717:function(e,t,n){var r=this&&this.__createBinding||(Object.create?function(e,t,n,r){if(r===undefined)r=n;Object.defineProperty(e,r,{enumerable:true,get:function(){return t[n]}})}:function(e,t,n,r){if(r===undefined)r=n;e[r]=t[n]});var o=this&&this.__setModuleDefault||(Object.create?function(e,t){Object.defineProperty(e,"default",{enumerable:true,value:t})}:function(e,t){e["default"]=t});var i=this&&this.__importStar||function(e){if(e&&e.__esModule)return e;var t={};if(e!=null)for(var n in e)if(n!=="default"&&Object.hasOwnProperty.call(e,n))r(t,e,n);o(t,e);return t};Object.defineProperty(t,"__esModule",{value:true});t.issueCommand=void 0;const s=i(n(747));const u=i(n(87));const a=n(278);function issueCommand(e,t){const n=process.env[`GITHUB_${e}`];if(!n){throw new Error(`Unable to find environment variable for file command ${e}`)}if(!s.existsSync(n)){throw new Error(`Missing file at path: ${n}`)}s.appendFileSync(n,`${a.toCommandValue(t)}${u.EOL}`,{encoding:"utf8"})}t.issueCommand=issueCommand},278:(e,t)=>{Object.defineProperty(t,"__esModule",{value:true});t.toCommandValue=void 0;function toCommandValue(e){if(e===null||e===undefined){return""}else if(typeof e==="string"||e instanceof String){return e}return JSON.stringify(e)}t.toCommandValue=toCommandValue},747:e=>{e.exports=require("fs")},211:e=>{e.exports=require("https")},87:e=>{e.exports=require("os")},622:e=>{e.exports=require("path")},191:e=>{e.exports=require("querystring")}};var t={};function __nccwpck_require__(n){var r=t[n];if(r!==undefined){return r.exports}var o=t[n]={exports:{}};var i=true;try{e[n].call(o.exports,o,o.exports,__nccwpck_require__);i=false}finally{if(i)delete t[n]}return o.exports}if(typeof __nccwpck_require__!=="undefined")__nccwpck_require__.ab=__dirname+"/";var n=__nccwpck_require__(109);module.exports=n})();