(function(t,n){typeof exports=="object"&&typeof module<"u"?n(exports,require("@kthksgy/procedure-call")):typeof define=="function"&&define.amd?define(["exports","@kthksgy/procedure-call"],n):(t=typeof globalThis<"u"?globalThis:t||self,n(t.KthksgyProcedureCallServiceWorker={},t.KthksgyProcedureCall))})(this,function(t,n){"use strict";const i=new Set;let r=!1;const l=n.callTarget;async function s(e){if(typeof e.data=="string"&&e.data.length>0){let a=!1;for(const o of i)(typeof o=="string"&&e.origin===o||o instanceof RegExp&&o.test(e.origin))&&(a=!0);if(a){const o=function(f,d){e.source!==null?e.source.postMessage(f):console.error(`[${n.NAME}] \`event.source\`が\`null\`であるため、手続き\`${d.name}\`のレスポンスを送信できません。`)};await n.handler(e.data,o)}}}function c(e){return typeof navigator=="object"&&navigator!==null&&typeof navigator.serviceWorker=="object"&&navigator.serviceWorker!==null?(e===void 0&&typeof window=="object"&&window!==null&&typeof window.location=="object"&&window.location!==null&&(e??(e=window.location.origin)),e!==void 0&&i.add(e),r||(navigator.serviceWorker.addEventListener("message",s),r=!0),function(){e!==void 0&&i.delete(e),i.size===0&&(navigator.serviceWorker.removeEventListener("message",s),r=!1)}):(console.error(`[${n.NAME}] Service Workerに対応していないため、Window Clientのソケット関数を開始できません。`),function(){})}t.callWindowClient=l,t.messageEventHandler=s,t.startMessageEventHandler=c,Object.defineProperty(t,Symbol.toStringTag,{value:"Module"})}); //# sourceMappingURL=index.umd.cjs.map