@withone/connect 0.23.0 → 0.24.0
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/README.md +4 -2
- package/dist/button.d.ts +5 -3
- package/dist/index.cjs.js +1 -1
- package/dist/index.esm.js +1 -1
- package/dist/server/index.cjs.js +36 -0
- package/dist/server/index.esm.js +36 -0
- package/dist/server/types.d.ts +20 -0
- package/package.json +1 -1
- package/skills/one-connect/SKILL.md +10 -4
- package/src/button.ts +18 -13
- package/src/server/index.ts +143 -31
- package/src/server/types.ts +24 -5
package/README.md
CHANGED
|
@@ -199,7 +199,7 @@ import { ConnectButton } from "@withone/connect/react";
|
|
|
199
199
|
| `logos` | Connector slugs to draw as logos. Decoration only; your permission set decides what One asks for. |
|
|
200
200
|
| `connected` | Whether the user already has a grant, from your server. |
|
|
201
201
|
| `variant` | `default`, `accent` (your brand colour), or `block` (a card with a `description`). Setting `accent` alone picks `accent`. |
|
|
202
|
-
| `accent` / `accentText` | Your brand colour (`"#F4A938"`) and the text on it. Leave `accentText` out and the button
|
|
202
|
+
| `accent` / `accentText` | Your brand colour (`"#F4A938"`) and the text on it. Leave `accentText` out and the button uses white text, or dark text on a colour too pale for white. |
|
|
203
203
|
| `size` | `sm`, `md` or `lg`. |
|
|
204
204
|
| `fullWidth` | Fills its container. |
|
|
205
205
|
| `theme` | `light`, `dark` or `auto`. `connectTheme` sets One's page. |
|
|
@@ -348,9 +348,11 @@ const reply = await oneConnect.runAction(userId, {
|
|
|
348
348
|
actionId: action._id,
|
|
349
349
|
body: { limit: 10 },
|
|
350
350
|
});
|
|
351
|
-
// { status, ok, blockedByGrant, refusal, data }
|
|
351
|
+
// { status, ok, blockedByGrant, refusal, rateLimit, data }
|
|
352
352
|
```
|
|
353
353
|
|
|
354
|
+
`rateLimit` is One's limit for that user after the call: `{ limit, remaining, resetsIn, retryAfter }`, calls per minute and seconds. The app owner's plan sets the size and each of your users has a bucket of their own. Slow down as `remaining` nears 0, and on a `429` wait `retryAfter` seconds. Any value One didn't send is `null`, `limit` and `remaining` are `null` when nothing limits the user, and `rateLimit` is `null` when One sent none of them. A `402` (`refusal: "plan_limit"`) means the user's calls for the month are used up: stop calling for them until next month rather than retrying.
|
|
355
|
+
|
|
354
356
|
Each connection carries its `access`: `{ policy: "full" }`, `{ policy: "methods", methods }` or `{ policy: "actions", actions }`. Plan from it before you call.
|
|
355
357
|
|
|
356
358
|
`runAction` does what the guide asks for: it fills `{{placeholders}}` in the path from `pathParams`, puts the connection key in the body of an action One serves itself, and sends the body the way the provider reads it.
|
package/dist/button.d.ts
CHANGED
|
@@ -2,9 +2,11 @@ import type { ConnectButtonHandle, ConnectButtonProps } from "./types";
|
|
|
2
2
|
/** @internal The variant drawn: the one asked for, else accent when a brand colour
|
|
3
3
|
* is given, else default. */
|
|
4
4
|
export declare const resolveVariant: (props: ConnectButtonProps) => import("./types").ConnectButtonVariant;
|
|
5
|
-
/**
|
|
6
|
-
*
|
|
7
|
-
*
|
|
5
|
+
/** White or dark text on a hex fill. White whenever it still reads, as on
|
|
6
|
+
* most brand buttons; dark only on fills pale enough to wash it out
|
|
7
|
+
* (yellow, lime, pastels). Measured with APCA, because WCAG's ratio puts
|
|
8
|
+
* black on mid-tones such as red, orange and blue. Null for anything that
|
|
9
|
+
* isn't a hex colour: the stylesheet's default stands. */
|
|
8
10
|
export declare function readableTextOn(fill: string): string | null;
|
|
9
11
|
/**
|
|
10
12
|
* Draws the button inside the shadow root of an element you render, for
|
package/dist/index.cjs.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
"use strict";const e="one_connect",t="one_connect_error",n={declined:"You cancelled the connection.",expired:"The connection attempt expired. Please try again.",failed:"The connection could not be completed. Please try again."};function o(o){const i=new URLSearchParams(o),r=i.get(e);if("success"===r)return{status:r};if("error"!==r)return null;const a=i.get(t),l=null!==(s=a)&&Object.prototype.hasOwnProperty.call(n,s)?a:"failed";var s;return{status:r,code:l,message:n[l]}}const i=[e,t,"one_connect_message"];function r(e){const t=new URLSearchParams(e);return i.some(e=>t.has(e))}let a,l=!1,s=!1,c=!1;const d=[];function p(){return u()}function u(){return"undefined"==typeof window?null:(void 0===a&&(a=o(window.location.search),(a||r(window.location.search))&&function(){const e=()=>{r(window.location.search)&&window.history.replaceState(window.history.state,"",function(e){const t=new URLSearchParams(e.search);for(const e of i)t.delete(e);const n=t.toString();return`${e.pathname}${n?`?${n}`:""}${e.hash}`}(window.location))};e();for(const t of[50,500,2e3])window.setTimeout(e,t)}()),a)}function h(e){let t=e,n=!1;const o={deliver:e=>{try{var n,o,i,r,a,l;"success"===e.status?null===(n=(o=t).onSuccess)||void 0===n||n.call(o):null===(i=(r=t).onError)||void 0===i||i.call(r,null!==(a=e.message)&&void 0!==a?a:"",null!==(l=e.code)&&void 0!==l?l:"failed")}catch{}},restored:()=>{if(n){n=!1;try{var e,o;null===(e=(o=t).onCancel)||void 0===e||e.call(o)}catch{}}}};return"undefined"!=typeof window&&(d.push(o),c||"undefined"==typeof window||(c=!0,window.addEventListener("pageshow",e=>{if(e.persisted)for(const e of[...d])e.restored()})),function(){if(l||s)return;const e=u();e&&(s=!0,window.setTimeout(()=>{s=!1;const t=d[0];t&&!l&&(l=!0,t.deliver(e))},0))}()),{open:()=>{"undefined"!=typeof window&&(n=!0,window.location.assign((e=>{try{var t,n;const o=new URL(e.authorizeUrl,window.location.origin);e.returnTo&&o.searchParams.set("one_return_to",e.returnTo);const i=new URLSearchParams;e.connectTheme&&i.set("one_theme",e.connectTheme);const r=null===(t=null!==(n=e.openApp)&&void 0!==n?n:e.connector)||void 0===t?void 0:t.trim().toLowerCase();r&&i.set("one_open_app",r);const a=i.toString();return a&&(o.hash=a),o.toString()}catch{return e.authorizeUrl}})(t)))},update:e=>{t=e},destroy:()=>{const e=d.indexOf(o);e>=0&&d.splice(e,1)}}}function C(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}const b={"cal-com":"Cal.com","click-up":"ClickUp",clickup:"ClickUp",docusign:"DocuSign",elevenlabs:"ElevenLabs","fireflies-ai":"Fireflies.ai",github:"GitHub",gitlab:"GitLab",hubspot:"HubSpot","linked-in":"LinkedIn",linkedin:"LinkedIn","one-drive":"OneDrive",onedrive:"OneDrive",openai:"OpenAI","otter-ai":"Otter.ai",paypal:"PayPal",posthog:"PostHog",quickbooks:"QuickBooks",sharepoint:"SharePoint","spotify-web":"Spotify",teams:"Microsoft Teams","telegram-bot":"Telegram","whatsapp-business":"WhatsApp Business",woocommerce:"WooCommerce",x:"X","youtube-data":"YouTube",youtube:"YouTube"};function v(e){var t;return null!==(t=b[e])&&void 0!==t?t:e.split(/[-_]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function g(e){return e?`https://assets.withone.ai/connectors/${e}.svg`:""}function m(e){var t,n,o,i;const r="string"==typeof e?{slug:e}:e,a=null!==(t=r.slug)&&void 0!==t&&t.trim()?f(r.slug):null!==(n=r.name)&&void 0!==n&&n.trim()?f(r.name):"";return a?{slug:a,name:(null===(o=r.name)||void 0===o?void 0:o.trim())||v(a),imageUrl:(null===(i=r.imageUrl)||void 0===i?void 0:i.trim())||g(a)}:null}function x(e){const t=null==e?void 0:e.trim();if(!t)return[];if(t.startsWith("["))try{const e=JSON.parse(t);return Array.isArray(e)?e.filter(e=>"string"==typeof e||"object"==typeof e&&null!==e):[]}catch{return[]}return t.split(",").map(e=>e.trim()).filter(Boolean)}const w="#CCFF00",y="#0A0C0B",k="#FFFFFF",A=`\n:host{display:inline-block;vertical-align:middle;max-width:100%}\n:host([data-full-width]),:host([full-width]:not([full-width="false"])),\n:host([data-variant="block"]),:host([variant="block"]){display:block;width:100%}\n.b{all:unset;box-sizing:border-box;position:relative;display:inline-flex;align-items:center;gap:var(--gap);\n max-width:100%;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent;\n font-family:var(--one-connect-font,inherit);font-size:var(--fs);font-weight:500;line-height:1.2;letter-spacing:-.01em;\n padding:var(--pad);border-radius:var(--one-connect-radius,12px);background:var(--bg);color:var(--fg);\n box-shadow:var(--shadow);transition:box-shadow .2s var(--ease),background-color .2s var(--ease),opacity .2s var(--ease)}\n.b[data-full-width]{display:flex;width:100%;justify-content:center}\n.b:focus-visible{outline:2px solid var(--ring);outline-offset:2px}\n.b:hover{box-shadow:var(--shadow-hover)}\n.b[disabled]{cursor:not-allowed;opacity:.5;box-shadow:none}\n.b[aria-busy="true"]{cursor:progress}\n.b{--ease:cubic-bezier(.2,.9,.25,1)}\n.b[data-size="sm"]{--fs:13px;--pad:8px 12px 8px 10px;--gap:8px;--chip:18px;--logo:14px}\n.b[data-size="md"]{--fs:14.5px;--pad:12px 16px 12px 14px;--gap:12px;--chip:22px;--logo:16px}\n.b[data-size="lg"]{--fs:16px;--pad:14px 20px 14px 16px;--gap:12px;--chip:26px;--logo:19px}\n.b[data-theme="light"],.b[data-theme="auto"]{--ink-bg:${y};--ink-fg:${k};--surface:${k};--surface-fg:${y};\n --muted:#5B6560;--line:#D5DAD7;--ring:${y};--shadow-base:0 1px 2px rgba(10,12,11,.08),0 4px 14px rgba(10,12,11,.06);\n --shadow-strong:0 1px 2px rgba(10,12,11,.12),0 6px 18px rgba(10,12,11,.1)}\n.b[data-theme="dark"]{--ink-bg:#F2F5F3;--ink-fg:${y};--surface:#101312;--surface-fg:#F2F5F3;\n --muted:#9AA39E;--line:#2A302D;--ring:${w};--shadow-base:0 1px 2px rgba(0,0,0,.4),0 8px 24px rgba(0,0,0,.35);\n --shadow-strong:0 1px 2px rgba(0,0,0,.5),0 10px 28px rgba(0,0,0,.45)}\n@media (prefers-color-scheme:dark){.b[data-theme="auto"]{--ink-bg:#F2F5F3;--ink-fg:${y};--surface:#101312;--surface-fg:#F2F5F3;\n --muted:#9AA39E;--line:#2A302D;--ring:${w};--shadow-base:0 1px 2px rgba(0,0,0,.4),0 8px 24px rgba(0,0,0,.35);\n --shadow-strong:0 1px 2px rgba(0,0,0,.5),0 10px 28px rgba(0,0,0,.45)}}\n.b[data-variant="default"]{--bg:var(--ink-bg);--fg:var(--ink-fg);--shadow:var(--shadow-base);--shadow-hover:var(--shadow-strong)}\n.b[data-variant="accent"]{--bg:var(--one-connect-accent,${w});--fg:var(--one-connect-accent-fg,${y});\n --shadow:0 1px 2px rgba(10,12,11,.1);--shadow-hover:0 1px 2px rgba(10,12,11,.12),0 6px 18px rgba(10,12,11,.12)}\n.b[data-variant="block"]{--bg:var(--surface);--fg:var(--surface-fg);--shadow:inset 0 0 0 1px var(--line);\n --shadow-hover:inset 0 0 0 1px var(--muted);flex-direction:column;align-items:stretch;gap:0;\n width:100%;max-width:420px;text-align:left;padding:16px;border-radius:var(--one-connect-radius,14px)}\n.b[data-variant="block"][data-full-width]{max-width:none}\n.stack{display:inline-flex;align-items:center;flex-shrink:0}\n.chip{width:var(--chip);height:var(--chip);border-radius:6px;display:grid;place-items:center;overflow:hidden;\n margin-left:-7px;position:relative;background:${k};color:${y};box-shadow:0 0 0 1.5px var(--bg);\n transition:margin-left .28s var(--ease)}\n.chip:first-child{margin-left:0}\n.b[data-variant="block"] .chip{box-shadow:0 0 0 1.5px var(--bg),0 0 0 2.5px var(--line)}\n.chip img{width:var(--logo);height:var(--logo);display:block;object-fit:contain}\n.chip.more,.chip.letter{font:500 9px/1 ui-monospace,SFMono-Regular,Menlo,monospace;letter-spacing:-.02em}\n.chip.letter{font-size:10px;font-weight:600}\n.b:hover .chip{margin-left:-2px}.b:hover .chip:first-child{margin-left:0}\n.label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.icon{display:inline-flex;flex-shrink:0}\n.arrow{opacity:.55;transition:transform .2s var(--ease),opacity .2s var(--ease)}\n.b:hover .arrow{transform:translateX(2px);opacity:.85}\n.spinner{width:16px;height:16px;border-radius:50%;border:2px solid currentColor;border-top-color:transparent;\n opacity:.7;animation:spin .7s linear infinite;flex-shrink:0}\n@keyframes spin{to{transform:rotate(360deg)}}\n.top{display:flex;align-items:center;justify-content:space-between;gap:12px}\n.title{font-size:15px;font-weight:600;letter-spacing:-.01em}\n.sub{font-size:13px;line-height:1.5;margin-top:6px;font-weight:400;color:var(--muted)}\n.foot{margin-top:14px;padding-top:12px;display:flex;align-items:center;gap:6px;font-size:11px;font-weight:400;\n color:var(--muted);border-top:1px solid var(--line)}\n.lockup{display:inline-flex;color:var(--surface-fg)}\n.sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}\n@media (prefers-reduced-motion:reduce){.b,.chip,.arrow{transition:none}.spinner{animation-duration:1.6s}}\n@media (forced-colors:active){.b{border:1px solid ButtonText}.b:focus-visible{outline-color:Highlight}}\n`;let S=null;const L=(e,t,n)=>{const o=document.createElement(e);return t&&(o.className=t),void 0!==n&&(o.textContent=n),o},E=(e,t="icon")=>{const n=L("span",t);return n.innerHTML=e,n};function T(e){const t=(null!=(n=e.logos)?n:[]).map(m).filter(e=>null!==e);var n;if(0===t.length)return null;const o=L("span","stack");o.setAttribute("aria-hidden","true");for(const e of t.slice(0,3)){const t=L("span","chip");t.title=e.name;const n=L("img");n.alt="",n.decoding="async",n.src=e.imageUrl,n.addEventListener("error",()=>{n.remove(),t.classList.add("letter"),t.textContent=e.name.charAt(0).toUpperCase()}),t.appendChild(n),o.appendChild(t)}const i=t.length-3;return i>0&&o.appendChild(L("span","chip more",`+${i}`)),o}const z=e=>{var t;return null!==(t=e.variant)&&void 0!==t?t:e.accent?"accent":"default"};function F(e,t){var n,o;const i=null===(n=t.accent)||void 0===n?void 0:n.trim(),r=(null===(o=t.accentText)||void 0===o?void 0:o.trim())||(i?function(e){const t=e.trim().replace(/^#/,""),n=3===t.length?t.split("").map(e=>e+e).join(""):t;if(!/^[0-9a-f]{6}$/i.test(n))return null;const o=e=>{const t=parseInt(n.slice(e,e+2),16)/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},i=.2126*o(0)+.7152*o(2)+.0722*o(4);return(i+.05)/(.0037+.05)>=1.05/(i+.05)?y:k}(i):null);i?e.style.setProperty("--one-connect-accent",i):e.style.removeProperty("--one-connect-accent"),r?e.style.setProperty("--one-connect-accent-fg",r):e.style.removeProperty("--one-connect-accent-fg"),e.getAttribute("style")||e.removeAttribute("style")}const M=(e,t)=>{var n;return{authorizeUrl:e.authorizeUrl,connectTheme:e.connectTheme,openApp:null!==(n=e.openApp)&&void 0!==n?n:e.connector,returnTo:e.returnTo,...t}};function $(e,t){var n;const o=null!==(n=e.shadowRoot)&&void 0!==n?n:e.attachShadow({mode:"open"});!function(e){if("undefined"!=typeof CSSStyleSheet&&"replaceSync"in CSSStyleSheet.prototype&&"adoptedStyleSheets"in e)try{return S||(S=new CSSStyleSheet,S.replaceSync(A)),void(e.adoptedStyleSheets=[S])}catch{}const t=document.createElement("style");t.textContent=A,e.appendChild(t)}(o);let i=t,r=!1,a=!1,l=null;const s=L("button","b");s.type="button",s.setAttribute("part","button");const c=L("span","sr");c.setAttribute("role","status"),c.setAttribute("aria-live","polite"),o.append(s,c);const d=()=>{return r?"connecting":void 0!==i.connected?i.connected?"connected":"idle":"success"===(null===(e=p())||void 0===e?void 0:e.status)?"connected":"idle";var e},u={onSuccess:()=>{var e,t;return null===(e=(t=i).onSuccess)||void 0===e?void 0:e.call(t)},onError:(e,t)=>{var n,o;return null===(n=(o=i).onError)||void 0===n?void 0:n.call(o,e,t)},onCancel:()=>{var e,t;r=!1,f(),null===(e=(t=i).onCancel)||void 0===e||e.call(t)}},C=h(M(i,u)),f=()=>{var e,t,n,o;if(a)return;const r=d(),p=z(i),u="connecting"===r?"Connecting…":"connected"===r?null!==(e=i.connectedLabel)&&void 0!==e?e:"Connected":null!==(t=i.label)&&void 0!==t?t:"Connect your apps";s.dataset.variant=p,F(s,i),s.dataset.size=null!==(n=i.size)&&void 0!==n?n:"md",s.dataset.theme=null!==(o=i.theme)&&void 0!==o?o:"light",s.dataset.state=r,s.toggleAttribute("data-full-width",Boolean(i.fullWidth)),s.disabled=Boolean(i.disabled),s.setAttribute("aria-busy",String("connecting"===r)),"connecting"===r?s.setAttribute("aria-disabled","true"):s.removeAttribute("aria-disabled");const h="idle"===r?T(i):null,C="connecting"===r?L("span","spinner"):"connected"===r?E('<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M3 8.5l3.5 3.5L13 5"/></svg>'):h;if(s.replaceChildren(),s.removeAttribute("aria-labelledby"),s.removeAttribute("aria-describedby"),"block"===p){const e=L("span","top"),t=L("span","title",u);if(t.id="one-connect-title",t.setAttribute("part","label"),e.appendChild(t),C&&e.appendChild(C),s.appendChild(e),s.setAttribute("aria-labelledby",t.id),i.description){const e=L("span","sub",i.description);e.id="one-connect-description",s.appendChild(e),s.setAttribute("aria-describedby",e.id)}const n=L("span","foot");n.setAttribute("aria-hidden","true"),n.append(L("span","","Secured by"),E('<svg viewBox="0 0 3152 990" width="35" height="11" fill="none" aria-hidden="true" focusable="false"><path d="M1698.02 793.203C1525.75 793.203 1401 666.834 1401 495.102C1401 323.909 1524.67 197 1698.02 197C1870.83 197 1996.12 323.909 1996.12 495.102C1996.12 666.834 1869.75 793.203 1698.02 793.203ZM1698.02 694.916C1801.71 694.916 1884.88 615.53 1884.88 495.102C1884.88 374.133 1801.71 295.827 1698.02 295.827C1594.87 295.827 1511.71 373.053 1511.71 495.102C1511.71 616.61 1595.41 694.916 1698.02 694.916Z" fill="currentColor"/><path d="M2326.71 197.54C2480.62 197.54 2565.95 289.887 2565.95 467.56V779.702H2455.24V468.64C2455.24 361.172 2411.5 292.587 2308.35 292.587C2217.63 292.587 2140.4 356.852 2140.4 484.841V779.702H2030.77V211.041H2140.4V272.065C2185.76 225.082 2248.41 197.54 2326.71 197.54Z" fill="currentColor"/><path d="M3151.98 493.481C3151.98 514.003 3150.36 520.483 3148.74 529.124H2700.51C2715.63 637.672 2794.47 686.815 2922.46 686.815C3031.01 686.815 3099.6 650.633 3116.88 643.072V747.84C3100.68 755.4 3023.45 793.203 2908.96 793.203C2699.97 793.203 2588.18 661.434 2588.18 497.802C2588.18 332.55 2702.67 197 2871.7 197C3031.55 197 3151.98 317.969 3151.98 493.481ZM2876.02 300.688C2784.75 300.688 2720.49 345.511 2702.67 434.617H3050.45C3034.79 344.971 2967.29 300.688 2876.02 300.688Z" fill="currentColor"/><path d="M537.494 782.175C641.011 827.7 767.922 858.83 880.501 839.875C983.155 822.599 1069.64 764.946 1094.39 659.271C1114.47 573.493 1088.54 481.273 1047.27 405.311C983.124 287.246 874.768 183.791 759.847 114.657C644.926 45.5225 507.181 -5.02605 372.102 0.398669C289.698 3.69665 205.938 26.536 146.544 85.6685C112.069 119.989 88.3818 171.231 83.1266 219.823C78.1642 265.64 84.3749 310.317 99.8478 354.007C168.243 547.14 354.009 701.467 537.51 782.191L537.494 782.175ZM751.956 818.053C583.05 796.2 415.7 707.108 292.472 593.004C222.536 528.246 159.366 444.979 125.985 355.471C102.961 293.734 96.3956 223.367 122.41 161.969C137.158 127.14 160.367 98.244 190.743 75.9133C275.581 13.5752 395.819 6.99464 495.977 26.8596C608.848 49.252 713.875 99.4615 806.712 166.515C907.085 239.025 999.537 339.922 1048.42 454.627C1072.45 511.001 1083.99 570.103 1075.64 630.869C1067.38 690.957 1034.57 742.353 983.987 775.379C917.626 818.715 830.861 828.255 751.972 818.053H751.956Z" fill="currentColor"/><path d="M1103.27 661.228C1086.68 755.313 1024.9 818.622 934.021 848.69C821.751 885.846 685.146 860.263 576.251 818.915C452.515 771.942 340.336 699.91 245.157 607.813C209.002 572.83 177.255 534.456 148.837 493.031C100.384 422.402 61.7024 335.19 65.8326 248.071C68.2213 197.769 83.987 159.241 111.403 116.938C45.8289 171.308 31.404 262.511 47.1543 342.002C53.4728 373.841 62.9815 403.23 76.528 432.958C100.338 485.202 130.914 532.992 167.747 577.238C255.452 682.573 367.83 765.13 491.073 824.124C614.317 883.118 769.307 920.691 900.471 889.128C985.788 868.601 1061.47 816.095 1090.83 730.856C1098.18 708.71 1104.61 686.564 1103.25 661.244L1103.27 661.228Z" fill="currentColor"/><path d="M883.297 963.502C923.15 947.074 960.877 926.022 988.309 893.967C954.265 917.839 920.931 934.807 882.403 944.993C751.747 979.53 595.123 942.589 474.731 886.57C422.102 862.082 372.617 834.018 325.181 800.591C205.128 715.984 89.4825 597.996 36.7762 458.756C20.2092 414.973 11.7793 370.404 11.5327 323.739C11.4249 302.641 15.4627 283.747 19.0226 263.004C-2.52219 310.486 -3.66265 380.915 5.21419 431.617C32.0605 584.881 147.151 721.146 266.988 813.983C343.443 873.224 436.403 924.913 528.424 954.672C620.444 984.431 713.851 999.426 808.491 983.598C834.459 979.252 858.362 973.781 883.297 963.502Z" fill="currentColor"/><path d="M1045.09 830.737C1053.55 816.158 1061.75 802.95 1066.99 787.061C1043.75 824.541 1013.3 854.408 974.29 874.982C947.752 888.991 920.228 899.27 890.577 905.219C864.578 910.428 839.673 914.481 812.781 914.851C739.716 915.852 668.717 903.092 599.459 880.854C418.686 822.8 238.422 697.6 127.985 543.165C94.8819 496.87 68.8679 447.847 50.7135 394.031C28.1978 324.45 25.7782 258.69 53.4104 189.078C36.1345 211.825 26.9956 237.793 20.4151 264.916C18.3654 282.732 14.713 299.345 15.0828 317.561C15.9613 360.774 23.5436 402.692 38.477 443.562C73.1522 538.464 134.936 621.869 207.368 691.913C307.34 788.587 426.762 862.268 558.127 907.993C689.491 953.718 871.975 973.768 992.614 885.446C1013.28 870.312 1029.39 851.773 1045.07 830.752L1045.09 830.737Z" fill="currentColor"/><path d="M552.552 745.664C671.079 797.831 835.825 835.526 954.768 769.12C999.137 744.354 1031.99 705.626 1047.99 657.312C1086.75 540.264 1020.28 405.817 947.124 315.631C855.536 202.745 729.688 114.516 592.76 66.0323C506.349 35.4412 418.968 22.0797 328.211 37.46C262.313 48.6177 195.29 81.7054 157.563 138.234C118.912 196.133 115.891 270.785 136.758 335.882C176.519 459.926 276.769 570.763 381.01 646.277C434.995 685.391 491.662 718.864 552.567 745.664H552.552ZM210.162 422.955C199.898 402.381 189.141 382.701 184.733 360.385C182.267 347.918 184.625 333.477 184.564 320.64C184.44 293.223 194.072 269.059 209.992 247.93C219.609 235.17 229.456 224.844 243.018 215.906C341.218 151.179 476.051 175.991 576.763 223.904C661.971 264.435 737.394 321.534 796.11 395.862C836.919 447.52 871.193 513.634 880.502 579.501C888.238 634.272 873.243 695.485 826.763 729.189C807.853 742.905 785.045 751.721 761.728 755.974C721.921 763.217 688.802 758.008 649.565 748.916C594.27 736.094 542.488 715.212 492.279 688.889C441.977 662.521 396.745 631.483 353.008 595.436C314.372 563.597 280.252 537.845 248.458 498.007L248.274 497.837L221.504 461.945L211.379 445.84C194.103 418.408 177.398 391.346 165.238 361.202C151.291 326.604 142.676 291.852 143.678 254.279C146.19 160.564 203.766 96.7467 290.238 67.82C434.394 19.5985 611.561 79.4246 735.298 157.636C825.099 214.411 904.435 286.581 963.321 375.134C989.767 414.894 1010.42 456.998 1023.78 502.646C1049.84 591.66 1036.79 685.884 957.404 742.659C890.257 790.68 785.6 793.146 707.295 776.486C680.403 769.736 654.065 766.007 629.222 754.818C732.107 783.93 882.397 797.723 963.938 715.35C990.599 688.412 1007.55 656.218 1013.75 618.537C1020.87 575.232 1016.12 531.634 1002.62 489.931C985.498 437.071 956.34 384.026 922.405 340.289C876.911 281.665 823.188 230.531 762.468 187.981C681.112 130.975 588.783 88.887 490.799 71.0872C425.595 59.2514 349.463 60.4072 287.557 85.0959C256.441 97.5019 228.501 114.5 205.924 138.85C158.303 190.2 147.176 256.036 161.539 323.383C166.856 348.334 175.456 371.296 185.596 394.737C194.488 415.295 222.676 461.883 236.022 477.649L226.729 456.196L210.162 423.001V422.955ZM832.342 286.936C756.904 211.544 666.44 154.076 564.896 120.249C526.553 107.473 487.948 99.4899 447.648 96.084C401.26 92.1696 356.167 96.7313 312.215 111.341C222.337 141.208 169.399 217.277 175.255 312.333C177.567 324.847 179.555 335.774 180.603 348.503C152.971 264.944 174.454 175.236 251.356 125.581C310.797 87.2072 387.39 78.2071 456.694 86.7603C503.714 92.5549 555.387 106.656 599.078 124.317C706.016 167.546 800.764 234.615 876.741 321.395C912.002 361.664 942.085 405.756 963.876 454.532C996.779 528.166 1011.85 610.046 965.895 681.369C952.379 702.359 935.427 718.818 914.283 731.871C884.432 747.421 852.947 758.671 818.872 761.06C839.523 755.959 859.404 750.981 878.637 740.424C929.186 717.061 964.601 671.567 974.818 616.488C987.671 547.245 964.693 475.429 930.881 415.357C903.834 367.305 871.471 326.049 832.311 286.905L832.342 286.936ZM890.673 420.18C861.623 370.387 825.515 327.621 783.288 287.999C721.659 230.161 650.028 185.345 570.598 156.033C513.623 135.013 454.506 124.394 393.786 128.108C353.316 130.59 315.728 139.867 280.498 159.516C245.268 179.166 216.819 204.918 201.023 240.394L188.617 268.242C204.583 180.445 278.325 132.054 361.931 119.355C412.757 111.634 462.658 116.643 512.421 129.048C596.905 150.116 674.1 189.923 743.45 242.028C816.607 296.999 885.526 373.531 924.578 456.982C949.713 510.675 965.094 571.61 949.837 630.234C939.018 671.768 912.511 706.566 875.308 727.987C847.013 744.292 816.191 754.679 783.242 758.101C825.915 745.926 863.75 731.917 895.327 698.799C913.512 679.72 926.535 657.62 933.054 631.714C951.347 558.989 927.49 483.274 890.642 420.134L890.673 420.18ZM726.19 279.369C625.678 198.799 493.404 141.917 362.655 156.973C343.854 159.131 326.547 164.17 308.639 169.195C301.18 171.29 295.201 177.732 286.493 176.253C378.313 130.081 492.063 149.545 583.143 188.119C684.102 230.87 775.952 302.825 840.664 391.069C871.794 433.527 895.805 479.652 909.506 530.386C918.382 563.273 920.232 596.654 911.941 629.294C905.622 654.153 895.481 677.778 875.786 694.9C893.987 666.327 905.452 637.693 907.086 604.128C908.72 570.562 903.141 536.565 891.567 503.57C861.392 417.53 797.066 336.19 726.205 279.384L726.19 279.369Z" fill="currentColor"/></svg>',"lockup")),s.appendChild(n)}else{C&&s.appendChild(C);const e=L("span","label",u);e.setAttribute("part","label"),s.appendChild(e),"idle"===r&&s.appendChild(E('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M6 3l5 5-5 5"/></svg>',"icon arrow"))}var f,b;f=r,null!==l?f!==l&&(l=f,c.textContent="connecting"===f?"Connecting to One…":"connected"===f?null!==(b=i.connectedLabel)&&void 0!==b?b:"Connected":""):l=f};return s.addEventListener("click",()=>{a||i.disabled||r||(r=!0,f(),C.open())}),f(),{update:e=>{i=e,C.update(M(i,u)),f()},destroy:()=>{a=!0,C.destroy(),o.replaceChildren()}}}const P=["authorize-url","logos","connected","disabled","variant","size","full-width","theme","connect-theme","open-app","connector","return-to","label","connected-label","description","accent","accent-text"];function U(e,t,n){const o=e.getAttribute(t);return o&&n.includes(o)?o:void 0}const B=(e,t)=>e.hasAttribute(t)?"false"!==e.getAttribute(t):void 0;function Z(){if("undefined"!=typeof window&&"undefined"!=typeof customElements&&!customElements.get("one-connect-button")){class e extends HTMLElement{constructor(...e){super(...e),C(this,"onSuccess",null),C(this,"onError",null),C(this,"onCancel",null),C(this,"handle",null)}connectedCallback(){this.sync()}disconnectedCallback(){var e;null===(e=this.handle)||void 0===e||e.destroy(),this.handle=null}attributeChangedCallback(){this.isConnected&&this.sync()}props(e){var t,n,o,i,r,a,l,s;return{authorizeUrl:e,logos:x(this.getAttribute("logos")),connected:B(this,"connected"),disabled:B(this,"disabled"),variant:U(this,"variant",["default","accent","block"]),size:U(this,"size",["sm","md","lg"]),fullWidth:B(this,"full-width"),theme:U(this,"theme",["light","dark","auto"]),connectTheme:U(this,"connect-theme",["light","dark"]),openApp:null!==(t=null!==(n=this.getAttribute("open-app"))&&void 0!==n?n:this.getAttribute("connector"))&&void 0!==t?t:void 0,returnTo:null!==(o=this.getAttribute("return-to"))&&void 0!==o?o:void 0,label:null!==(i=this.getAttribute("label"))&&void 0!==i?i:void 0,connectedLabel:null!==(r=this.getAttribute("connected-label"))&&void 0!==r?r:void 0,description:null!==(a=this.getAttribute("description"))&&void 0!==a?a:void 0,accent:null!==(l=this.getAttribute("accent"))&&void 0!==l?l:void 0,accentText:null!==(s=this.getAttribute("accent-text"))&&void 0!==s?s:void 0,onSuccess:()=>{var e;null===(e=this.onSuccess)||void 0===e||e.call(this),this.dispatchEvent(new CustomEvent("success"))},onError:(e,t)=>{var n;null===(n=this.onError)||void 0===n||n.call(this,e,t),this.dispatchEvent(new CustomEvent("error",{detail:{message:e,code:t}}))},onCancel:()=>{var e;null===(e=this.onCancel)||void 0===e||e.call(this),this.dispatchEvent(new CustomEvent("cancel"))}}}sync(){const e=this.getAttribute("authorize-url");var t;if(!e)return null===(t=this.handle)||void 0===t||t.destroy(),void(this.handle=null);const n=this.props(e);this.handle?this.handle.update(n):this.handle=$(this,n)}}C(e,"observedAttributes",[...P]),customElements.define("one-connect-button",e)}}Z(),exports.createConnectFlow=h,exports.mountConnectButton=function(e,t){const n=document.createElement("span");n.className="one-connect";const o=e=>{n.setAttribute("data-variant",z(e)),n.toggleAttribute("data-full-width",Boolean(e.fullWidth))};o(t),e.appendChild(n);const i=$(n,t);return{update:e=>{o(e),i.update(e)},destroy:()=>{i.destroy(),n.remove()}}},exports.readConnectReturn=p,exports.registerConnectButton=Z,exports.renderConnectButton=$,exports.resolveVariant=z;
|
|
1
|
+
"use strict";const e="one_connect",t="one_connect_error",n={declined:"You cancelled the connection.",expired:"The connection attempt expired. Please try again.",failed:"The connection could not be completed. Please try again."};function o(o){const i=new URLSearchParams(o),r=i.get(e);if("success"===r)return{status:r};if("error"!==r)return null;const a=i.get(t),l=null!==(s=a)&&Object.prototype.hasOwnProperty.call(n,s)?a:"failed";var s;return{status:r,code:l,message:n[l]}}const i=[e,t,"one_connect_message"];function r(e){const t=new URLSearchParams(e);return i.some(e=>t.has(e))}let a,l=!1,s=!1,c=!1;const d=[];function p(){return u()}function u(){return"undefined"==typeof window?null:(void 0===a&&(a=o(window.location.search),(a||r(window.location.search))&&function(){const e=()=>{r(window.location.search)&&window.history.replaceState(window.history.state,"",function(e){const t=new URLSearchParams(e.search);for(const e of i)t.delete(e);const n=t.toString();return`${e.pathname}${n?`?${n}`:""}${e.hash}`}(window.location))};e();for(const t of[50,500,2e3])window.setTimeout(e,t)}()),a)}function h(e){let t=e,n=!1;const o={deliver:e=>{try{var n,o,i,r,a,l;"success"===e.status?null===(n=(o=t).onSuccess)||void 0===n||n.call(o):null===(i=(r=t).onError)||void 0===i||i.call(r,null!==(a=e.message)&&void 0!==a?a:"",null!==(l=e.code)&&void 0!==l?l:"failed")}catch{}},restored:()=>{if(n){n=!1;try{var e,o;null===(e=(o=t).onCancel)||void 0===e||e.call(o)}catch{}}}};return"undefined"!=typeof window&&(d.push(o),c||"undefined"==typeof window||(c=!0,window.addEventListener("pageshow",e=>{if(e.persisted)for(const e of[...d])e.restored()})),function(){if(l||s)return;const e=u();e&&(s=!0,window.setTimeout(()=>{s=!1;const t=d[0];t&&!l&&(l=!0,t.deliver(e))},0))}()),{open:()=>{"undefined"!=typeof window&&(n=!0,window.location.assign((e=>{try{var t,n;const o=new URL(e.authorizeUrl,window.location.origin);e.returnTo&&o.searchParams.set("one_return_to",e.returnTo);const i=new URLSearchParams;e.connectTheme&&i.set("one_theme",e.connectTheme);const r=null===(t=null!==(n=e.openApp)&&void 0!==n?n:e.connector)||void 0===t?void 0:t.trim().toLowerCase();r&&i.set("one_open_app",r);const a=i.toString();return a&&(o.hash=a),o.toString()}catch{return e.authorizeUrl}})(t)))},update:e=>{t=e},destroy:()=>{const e=d.indexOf(o);e>=0&&d.splice(e,1)}}}function C(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}const b={"cal-com":"Cal.com","click-up":"ClickUp",clickup:"ClickUp",docusign:"DocuSign",elevenlabs:"ElevenLabs","fireflies-ai":"Fireflies.ai",github:"GitHub",gitlab:"GitLab",hubspot:"HubSpot","linked-in":"LinkedIn",linkedin:"LinkedIn","one-drive":"OneDrive",onedrive:"OneDrive",openai:"OpenAI","otter-ai":"Otter.ai",paypal:"PayPal",posthog:"PostHog",quickbooks:"QuickBooks",sharepoint:"SharePoint","spotify-web":"Spotify",teams:"Microsoft Teams","telegram-bot":"Telegram","whatsapp-business":"WhatsApp Business",woocommerce:"WooCommerce",x:"X","youtube-data":"YouTube",youtube:"YouTube"};function v(e){var t;return null!==(t=b[e])&&void 0!==t?t:e.split(/[-_]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function g(e){return e?`https://assets.withone.ai/connectors/${e}.svg`:""}function m(e){var t,n,o,i;const r="string"==typeof e?{slug:e}:e,a=null!==(t=r.slug)&&void 0!==t&&t.trim()?f(r.slug):null!==(n=r.name)&&void 0!==n&&n.trim()?f(r.name):"";return a?{slug:a,name:(null===(o=r.name)||void 0===o?void 0:o.trim())||v(a),imageUrl:(null===(i=r.imageUrl)||void 0===i?void 0:i.trim())||g(a)}:null}function x(e){const t=null==e?void 0:e.trim();if(!t)return[];if(t.startsWith("["))try{const e=JSON.parse(t);return Array.isArray(e)?e.filter(e=>"string"==typeof e||"object"==typeof e&&null!==e):[]}catch{return[]}return t.split(",").map(e=>e.trim()).filter(Boolean)}const w="#CCFF00",y="#0A0C0B",k="#FFFFFF",A=`\n:host{display:inline-block;vertical-align:middle;max-width:100%}\n:host([data-full-width]),:host([full-width]:not([full-width="false"])),\n:host([data-variant="block"]),:host([variant="block"]){display:block;width:100%}\n.b{all:unset;box-sizing:border-box;position:relative;display:inline-flex;align-items:center;gap:var(--gap);\n max-width:100%;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent;\n font-family:var(--one-connect-font,inherit);font-size:var(--fs);font-weight:500;line-height:1.2;letter-spacing:-.01em;\n padding:var(--pad);border-radius:var(--one-connect-radius,12px);background:var(--bg);color:var(--fg);\n box-shadow:var(--shadow);transition:box-shadow .2s var(--ease),background-color .2s var(--ease),opacity .2s var(--ease)}\n.b[data-full-width]{display:flex;width:100%;justify-content:center}\n.b:focus-visible{outline:2px solid var(--ring);outline-offset:2px}\n.b:hover{box-shadow:var(--shadow-hover)}\n.b[disabled]{cursor:not-allowed;opacity:.5;box-shadow:none}\n.b[aria-busy="true"]{cursor:progress}\n.b{--ease:cubic-bezier(.2,.9,.25,1)}\n.b[data-size="sm"]{--fs:13px;--pad:8px 12px 8px 10px;--gap:8px;--chip:18px;--logo:14px}\n.b[data-size="md"]{--fs:14.5px;--pad:12px 16px 12px 14px;--gap:12px;--chip:22px;--logo:16px}\n.b[data-size="lg"]{--fs:16px;--pad:14px 20px 14px 16px;--gap:12px;--chip:26px;--logo:19px}\n.b[data-theme="light"],.b[data-theme="auto"]{--ink-bg:${y};--ink-fg:${k};--surface:${k};--surface-fg:${y};\n --muted:#5B6560;--line:#D5DAD7;--ring:${y};--shadow-base:0 1px 2px rgba(10,12,11,.08),0 4px 14px rgba(10,12,11,.06);\n --shadow-strong:0 1px 2px rgba(10,12,11,.12),0 6px 18px rgba(10,12,11,.1)}\n.b[data-theme="dark"]{--ink-bg:#F2F5F3;--ink-fg:${y};--surface:#101312;--surface-fg:#F2F5F3;\n --muted:#9AA39E;--line:#2A302D;--ring:${w};--shadow-base:0 1px 2px rgba(0,0,0,.4),0 8px 24px rgba(0,0,0,.35);\n --shadow-strong:0 1px 2px rgba(0,0,0,.5),0 10px 28px rgba(0,0,0,.45)}\n@media (prefers-color-scheme:dark){.b[data-theme="auto"]{--ink-bg:#F2F5F3;--ink-fg:${y};--surface:#101312;--surface-fg:#F2F5F3;\n --muted:#9AA39E;--line:#2A302D;--ring:${w};--shadow-base:0 1px 2px rgba(0,0,0,.4),0 8px 24px rgba(0,0,0,.35);\n --shadow-strong:0 1px 2px rgba(0,0,0,.5),0 10px 28px rgba(0,0,0,.45)}}\n.b[data-variant="default"]{--bg:var(--ink-bg);--fg:var(--ink-fg);--shadow:var(--shadow-base);--shadow-hover:var(--shadow-strong)}\n.b[data-variant="accent"]{--bg:var(--one-connect-accent,${w});--fg:var(--one-connect-accent-fg,${y});\n --shadow:0 1px 2px rgba(10,12,11,.1);--shadow-hover:0 1px 2px rgba(10,12,11,.12),0 6px 18px rgba(10,12,11,.12)}\n.b[data-variant="block"]{--bg:var(--surface);--fg:var(--surface-fg);--shadow:inset 0 0 0 1px var(--line);\n --shadow-hover:inset 0 0 0 1px var(--muted);flex-direction:column;align-items:stretch;gap:0;\n width:100%;max-width:420px;text-align:left;padding:16px;border-radius:var(--one-connect-radius,14px)}\n.b[data-variant="block"][data-full-width]{max-width:none}\n.stack{display:inline-flex;align-items:center;flex-shrink:0}\n.chip{width:var(--chip);height:var(--chip);border-radius:6px;display:grid;place-items:center;overflow:hidden;\n margin-left:-7px;position:relative;background:${k};color:${y};box-shadow:0 0 0 1.5px var(--bg);\n transition:margin-left .28s var(--ease)}\n.chip:first-child{margin-left:0}\n.b[data-variant="block"] .chip{box-shadow:0 0 0 1.5px var(--bg),0 0 0 2.5px var(--line)}\n.chip img{width:var(--logo);height:var(--logo);display:block;object-fit:contain}\n.chip.more,.chip.letter{font:500 9px/1 ui-monospace,SFMono-Regular,Menlo,monospace;letter-spacing:-.02em}\n.chip.letter{font-size:10px;font-weight:600}\n.b:hover .chip{margin-left:-2px}.b:hover .chip:first-child{margin-left:0}\n.label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.icon{display:inline-flex;flex-shrink:0}\n.arrow{opacity:.55;transition:transform .2s var(--ease),opacity .2s var(--ease)}\n.b:hover .arrow{transform:translateX(2px);opacity:.85}\n.spinner{width:16px;height:16px;border-radius:50%;border:2px solid currentColor;border-top-color:transparent;\n opacity:.7;animation:spin .7s linear infinite;flex-shrink:0}\n@keyframes spin{to{transform:rotate(360deg)}}\n.top{display:flex;align-items:center;justify-content:space-between;gap:12px}\n.title{font-size:15px;font-weight:600;letter-spacing:-.01em}\n.sub{font-size:13px;line-height:1.5;margin-top:6px;font-weight:400;color:var(--muted)}\n.foot{margin-top:14px;padding-top:12px;display:flex;align-items:center;gap:6px;font-size:11px;font-weight:400;\n color:var(--muted);border-top:1px solid var(--line)}\n.lockup{display:inline-flex;color:var(--surface-fg)}\n.sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}\n@media (prefers-reduced-motion:reduce){.b,.chip,.arrow{transition:none}.spinner{animation-duration:1.6s}}\n@media (forced-colors:active){.b{border:1px solid ButtonText}.b:focus-visible{outline-color:Highlight}}\n`;let S=null;const L=(e,t,n)=>{const o=document.createElement(e);return t&&(o.className=t),void 0!==n&&(o.textContent=n),o},E=(e,t="icon")=>{const n=L("span",t);return n.innerHTML=e,n};function T(e){const t=(null!=(n=e.logos)?n:[]).map(m).filter(e=>null!==e);var n;if(0===t.length)return null;const o=L("span","stack");o.setAttribute("aria-hidden","true");for(const e of t.slice(0,3)){const t=L("span","chip");t.title=e.name;const n=L("img");n.alt="",n.decoding="async",n.src=e.imageUrl,n.addEventListener("error",()=>{n.remove(),t.classList.add("letter"),t.textContent=e.name.charAt(0).toUpperCase()}),t.appendChild(n),o.appendChild(t)}const i=t.length-3;return i>0&&o.appendChild(L("span","chip more",`+${i}`)),o}const z=e=>{var t;return null!==(t=e.variant)&&void 0!==t?t:e.accent?"accent":"default"};function F(e,t){var n,o;const i=null===(n=t.accent)||void 0===n?void 0:n.trim(),r=(null===(o=t.accentText)||void 0===o?void 0:o.trim())||(i?function(e){const t=e.trim().replace(/^#/,""),n=3===t.length?t.split("").map(e=>e+e).join(""):t;if(!/^[0-9a-f]{6}$/i.test(n))return null;const o=e=>(parseInt(n.slice(e,e+2),16)/255)**2.4,i=.2126729*o(0)+.7151522*o(2)+.072175*o(4);return 100*(1.14*(1-(i>.022?i:i+(.022-i)**1.414)**.65)-.027)>=45?k:y}(i):null);i?e.style.setProperty("--one-connect-accent",i):e.style.removeProperty("--one-connect-accent"),r?e.style.setProperty("--one-connect-accent-fg",r):e.style.removeProperty("--one-connect-accent-fg"),e.getAttribute("style")||e.removeAttribute("style")}const M=(e,t)=>{var n;return{authorizeUrl:e.authorizeUrl,connectTheme:e.connectTheme,openApp:null!==(n=e.openApp)&&void 0!==n?n:e.connector,returnTo:e.returnTo,...t}};function $(e,t){var n;const o=null!==(n=e.shadowRoot)&&void 0!==n?n:e.attachShadow({mode:"open"});!function(e){if("undefined"!=typeof CSSStyleSheet&&"replaceSync"in CSSStyleSheet.prototype&&"adoptedStyleSheets"in e)try{return S||(S=new CSSStyleSheet,S.replaceSync(A)),void(e.adoptedStyleSheets=[S])}catch{}const t=document.createElement("style");t.textContent=A,e.appendChild(t)}(o);let i=t,r=!1,a=!1,l=null;const s=L("button","b");s.type="button",s.setAttribute("part","button");const c=L("span","sr");c.setAttribute("role","status"),c.setAttribute("aria-live","polite"),o.append(s,c);const d=()=>{return r?"connecting":void 0!==i.connected?i.connected?"connected":"idle":"success"===(null===(e=p())||void 0===e?void 0:e.status)?"connected":"idle";var e},u={onSuccess:()=>{var e,t;return null===(e=(t=i).onSuccess)||void 0===e?void 0:e.call(t)},onError:(e,t)=>{var n,o;return null===(n=(o=i).onError)||void 0===n?void 0:n.call(o,e,t)},onCancel:()=>{var e,t;r=!1,f(),null===(e=(t=i).onCancel)||void 0===e||e.call(t)}},C=h(M(i,u)),f=()=>{var e,t,n,o;if(a)return;const r=d(),p=z(i),u="connecting"===r?"Connecting…":"connected"===r?null!==(e=i.connectedLabel)&&void 0!==e?e:"Connected":null!==(t=i.label)&&void 0!==t?t:"Connect your apps";s.dataset.variant=p,F(s,i),s.dataset.size=null!==(n=i.size)&&void 0!==n?n:"md",s.dataset.theme=null!==(o=i.theme)&&void 0!==o?o:"light",s.dataset.state=r,s.toggleAttribute("data-full-width",Boolean(i.fullWidth)),s.disabled=Boolean(i.disabled),s.setAttribute("aria-busy",String("connecting"===r)),"connecting"===r?s.setAttribute("aria-disabled","true"):s.removeAttribute("aria-disabled");const h="idle"===r?T(i):null,C="connecting"===r?L("span","spinner"):"connected"===r?E('<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M3 8.5l3.5 3.5L13 5"/></svg>'):h;if(s.replaceChildren(),s.removeAttribute("aria-labelledby"),s.removeAttribute("aria-describedby"),"block"===p){const e=L("span","top"),t=L("span","title",u);if(t.id="one-connect-title",t.setAttribute("part","label"),e.appendChild(t),C&&e.appendChild(C),s.appendChild(e),s.setAttribute("aria-labelledby",t.id),i.description){const e=L("span","sub",i.description);e.id="one-connect-description",s.appendChild(e),s.setAttribute("aria-describedby",e.id)}const n=L("span","foot");n.setAttribute("aria-hidden","true"),n.append(L("span","","Secured by"),E('<svg viewBox="0 0 3152 990" width="35" height="11" fill="none" aria-hidden="true" focusable="false"><path d="M1698.02 793.203C1525.75 793.203 1401 666.834 1401 495.102C1401 323.909 1524.67 197 1698.02 197C1870.83 197 1996.12 323.909 1996.12 495.102C1996.12 666.834 1869.75 793.203 1698.02 793.203ZM1698.02 694.916C1801.71 694.916 1884.88 615.53 1884.88 495.102C1884.88 374.133 1801.71 295.827 1698.02 295.827C1594.87 295.827 1511.71 373.053 1511.71 495.102C1511.71 616.61 1595.41 694.916 1698.02 694.916Z" fill="currentColor"/><path d="M2326.71 197.54C2480.62 197.54 2565.95 289.887 2565.95 467.56V779.702H2455.24V468.64C2455.24 361.172 2411.5 292.587 2308.35 292.587C2217.63 292.587 2140.4 356.852 2140.4 484.841V779.702H2030.77V211.041H2140.4V272.065C2185.76 225.082 2248.41 197.54 2326.71 197.54Z" fill="currentColor"/><path d="M3151.98 493.481C3151.98 514.003 3150.36 520.483 3148.74 529.124H2700.51C2715.63 637.672 2794.47 686.815 2922.46 686.815C3031.01 686.815 3099.6 650.633 3116.88 643.072V747.84C3100.68 755.4 3023.45 793.203 2908.96 793.203C2699.97 793.203 2588.18 661.434 2588.18 497.802C2588.18 332.55 2702.67 197 2871.7 197C3031.55 197 3151.98 317.969 3151.98 493.481ZM2876.02 300.688C2784.75 300.688 2720.49 345.511 2702.67 434.617H3050.45C3034.79 344.971 2967.29 300.688 2876.02 300.688Z" fill="currentColor"/><path d="M537.494 782.175C641.011 827.7 767.922 858.83 880.501 839.875C983.155 822.599 1069.64 764.946 1094.39 659.271C1114.47 573.493 1088.54 481.273 1047.27 405.311C983.124 287.246 874.768 183.791 759.847 114.657C644.926 45.5225 507.181 -5.02605 372.102 0.398669C289.698 3.69665 205.938 26.536 146.544 85.6685C112.069 119.989 88.3818 171.231 83.1266 219.823C78.1642 265.64 84.3749 310.317 99.8478 354.007C168.243 547.14 354.009 701.467 537.51 782.191L537.494 782.175ZM751.956 818.053C583.05 796.2 415.7 707.108 292.472 593.004C222.536 528.246 159.366 444.979 125.985 355.471C102.961 293.734 96.3956 223.367 122.41 161.969C137.158 127.14 160.367 98.244 190.743 75.9133C275.581 13.5752 395.819 6.99464 495.977 26.8596C608.848 49.252 713.875 99.4615 806.712 166.515C907.085 239.025 999.537 339.922 1048.42 454.627C1072.45 511.001 1083.99 570.103 1075.64 630.869C1067.38 690.957 1034.57 742.353 983.987 775.379C917.626 818.715 830.861 828.255 751.972 818.053H751.956Z" fill="currentColor"/><path d="M1103.27 661.228C1086.68 755.313 1024.9 818.622 934.021 848.69C821.751 885.846 685.146 860.263 576.251 818.915C452.515 771.942 340.336 699.91 245.157 607.813C209.002 572.83 177.255 534.456 148.837 493.031C100.384 422.402 61.7024 335.19 65.8326 248.071C68.2213 197.769 83.987 159.241 111.403 116.938C45.8289 171.308 31.404 262.511 47.1543 342.002C53.4728 373.841 62.9815 403.23 76.528 432.958C100.338 485.202 130.914 532.992 167.747 577.238C255.452 682.573 367.83 765.13 491.073 824.124C614.317 883.118 769.307 920.691 900.471 889.128C985.788 868.601 1061.47 816.095 1090.83 730.856C1098.18 708.71 1104.61 686.564 1103.25 661.244L1103.27 661.228Z" fill="currentColor"/><path d="M883.297 963.502C923.15 947.074 960.877 926.022 988.309 893.967C954.265 917.839 920.931 934.807 882.403 944.993C751.747 979.53 595.123 942.589 474.731 886.57C422.102 862.082 372.617 834.018 325.181 800.591C205.128 715.984 89.4825 597.996 36.7762 458.756C20.2092 414.973 11.7793 370.404 11.5327 323.739C11.4249 302.641 15.4627 283.747 19.0226 263.004C-2.52219 310.486 -3.66265 380.915 5.21419 431.617C32.0605 584.881 147.151 721.146 266.988 813.983C343.443 873.224 436.403 924.913 528.424 954.672C620.444 984.431 713.851 999.426 808.491 983.598C834.459 979.252 858.362 973.781 883.297 963.502Z" fill="currentColor"/><path d="M1045.09 830.737C1053.55 816.158 1061.75 802.95 1066.99 787.061C1043.75 824.541 1013.3 854.408 974.29 874.982C947.752 888.991 920.228 899.27 890.577 905.219C864.578 910.428 839.673 914.481 812.781 914.851C739.716 915.852 668.717 903.092 599.459 880.854C418.686 822.8 238.422 697.6 127.985 543.165C94.8819 496.87 68.8679 447.847 50.7135 394.031C28.1978 324.45 25.7782 258.69 53.4104 189.078C36.1345 211.825 26.9956 237.793 20.4151 264.916C18.3654 282.732 14.713 299.345 15.0828 317.561C15.9613 360.774 23.5436 402.692 38.477 443.562C73.1522 538.464 134.936 621.869 207.368 691.913C307.34 788.587 426.762 862.268 558.127 907.993C689.491 953.718 871.975 973.768 992.614 885.446C1013.28 870.312 1029.39 851.773 1045.07 830.752L1045.09 830.737Z" fill="currentColor"/><path d="M552.552 745.664C671.079 797.831 835.825 835.526 954.768 769.12C999.137 744.354 1031.99 705.626 1047.99 657.312C1086.75 540.264 1020.28 405.817 947.124 315.631C855.536 202.745 729.688 114.516 592.76 66.0323C506.349 35.4412 418.968 22.0797 328.211 37.46C262.313 48.6177 195.29 81.7054 157.563 138.234C118.912 196.133 115.891 270.785 136.758 335.882C176.519 459.926 276.769 570.763 381.01 646.277C434.995 685.391 491.662 718.864 552.567 745.664H552.552ZM210.162 422.955C199.898 402.381 189.141 382.701 184.733 360.385C182.267 347.918 184.625 333.477 184.564 320.64C184.44 293.223 194.072 269.059 209.992 247.93C219.609 235.17 229.456 224.844 243.018 215.906C341.218 151.179 476.051 175.991 576.763 223.904C661.971 264.435 737.394 321.534 796.11 395.862C836.919 447.52 871.193 513.634 880.502 579.501C888.238 634.272 873.243 695.485 826.763 729.189C807.853 742.905 785.045 751.721 761.728 755.974C721.921 763.217 688.802 758.008 649.565 748.916C594.27 736.094 542.488 715.212 492.279 688.889C441.977 662.521 396.745 631.483 353.008 595.436C314.372 563.597 280.252 537.845 248.458 498.007L248.274 497.837L221.504 461.945L211.379 445.84C194.103 418.408 177.398 391.346 165.238 361.202C151.291 326.604 142.676 291.852 143.678 254.279C146.19 160.564 203.766 96.7467 290.238 67.82C434.394 19.5985 611.561 79.4246 735.298 157.636C825.099 214.411 904.435 286.581 963.321 375.134C989.767 414.894 1010.42 456.998 1023.78 502.646C1049.84 591.66 1036.79 685.884 957.404 742.659C890.257 790.68 785.6 793.146 707.295 776.486C680.403 769.736 654.065 766.007 629.222 754.818C732.107 783.93 882.397 797.723 963.938 715.35C990.599 688.412 1007.55 656.218 1013.75 618.537C1020.87 575.232 1016.12 531.634 1002.62 489.931C985.498 437.071 956.34 384.026 922.405 340.289C876.911 281.665 823.188 230.531 762.468 187.981C681.112 130.975 588.783 88.887 490.799 71.0872C425.595 59.2514 349.463 60.4072 287.557 85.0959C256.441 97.5019 228.501 114.5 205.924 138.85C158.303 190.2 147.176 256.036 161.539 323.383C166.856 348.334 175.456 371.296 185.596 394.737C194.488 415.295 222.676 461.883 236.022 477.649L226.729 456.196L210.162 423.001V422.955ZM832.342 286.936C756.904 211.544 666.44 154.076 564.896 120.249C526.553 107.473 487.948 99.4899 447.648 96.084C401.26 92.1696 356.167 96.7313 312.215 111.341C222.337 141.208 169.399 217.277 175.255 312.333C177.567 324.847 179.555 335.774 180.603 348.503C152.971 264.944 174.454 175.236 251.356 125.581C310.797 87.2072 387.39 78.2071 456.694 86.7603C503.714 92.5549 555.387 106.656 599.078 124.317C706.016 167.546 800.764 234.615 876.741 321.395C912.002 361.664 942.085 405.756 963.876 454.532C996.779 528.166 1011.85 610.046 965.895 681.369C952.379 702.359 935.427 718.818 914.283 731.871C884.432 747.421 852.947 758.671 818.872 761.06C839.523 755.959 859.404 750.981 878.637 740.424C929.186 717.061 964.601 671.567 974.818 616.488C987.671 547.245 964.693 475.429 930.881 415.357C903.834 367.305 871.471 326.049 832.311 286.905L832.342 286.936ZM890.673 420.18C861.623 370.387 825.515 327.621 783.288 287.999C721.659 230.161 650.028 185.345 570.598 156.033C513.623 135.013 454.506 124.394 393.786 128.108C353.316 130.59 315.728 139.867 280.498 159.516C245.268 179.166 216.819 204.918 201.023 240.394L188.617 268.242C204.583 180.445 278.325 132.054 361.931 119.355C412.757 111.634 462.658 116.643 512.421 129.048C596.905 150.116 674.1 189.923 743.45 242.028C816.607 296.999 885.526 373.531 924.578 456.982C949.713 510.675 965.094 571.61 949.837 630.234C939.018 671.768 912.511 706.566 875.308 727.987C847.013 744.292 816.191 754.679 783.242 758.101C825.915 745.926 863.75 731.917 895.327 698.799C913.512 679.72 926.535 657.62 933.054 631.714C951.347 558.989 927.49 483.274 890.642 420.134L890.673 420.18ZM726.19 279.369C625.678 198.799 493.404 141.917 362.655 156.973C343.854 159.131 326.547 164.17 308.639 169.195C301.18 171.29 295.201 177.732 286.493 176.253C378.313 130.081 492.063 149.545 583.143 188.119C684.102 230.87 775.952 302.825 840.664 391.069C871.794 433.527 895.805 479.652 909.506 530.386C918.382 563.273 920.232 596.654 911.941 629.294C905.622 654.153 895.481 677.778 875.786 694.9C893.987 666.327 905.452 637.693 907.086 604.128C908.72 570.562 903.141 536.565 891.567 503.57C861.392 417.53 797.066 336.19 726.205 279.384L726.19 279.369Z" fill="currentColor"/></svg>',"lockup")),s.appendChild(n)}else{C&&s.appendChild(C);const e=L("span","label",u);e.setAttribute("part","label"),s.appendChild(e),"idle"===r&&s.appendChild(E('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M6 3l5 5-5 5"/></svg>',"icon arrow"))}var f,b;f=r,null!==l?f!==l&&(l=f,c.textContent="connecting"===f?"Connecting to One…":"connected"===f?null!==(b=i.connectedLabel)&&void 0!==b?b:"Connected":""):l=f};return s.addEventListener("click",()=>{a||i.disabled||r||(r=!0,f(),C.open())}),f(),{update:e=>{i=e,C.update(M(i,u)),f()},destroy:()=>{a=!0,C.destroy(),o.replaceChildren()}}}const P=["authorize-url","logos","connected","disabled","variant","size","full-width","theme","connect-theme","open-app","connector","return-to","label","connected-label","description","accent","accent-text"];function U(e,t,n){const o=e.getAttribute(t);return o&&n.includes(o)?o:void 0}const B=(e,t)=>e.hasAttribute(t)?"false"!==e.getAttribute(t):void 0;function Z(){if("undefined"!=typeof window&&"undefined"!=typeof customElements&&!customElements.get("one-connect-button")){class e extends HTMLElement{constructor(...e){super(...e),C(this,"onSuccess",null),C(this,"onError",null),C(this,"onCancel",null),C(this,"handle",null)}connectedCallback(){this.sync()}disconnectedCallback(){var e;null===(e=this.handle)||void 0===e||e.destroy(),this.handle=null}attributeChangedCallback(){this.isConnected&&this.sync()}props(e){var t,n,o,i,r,a,l,s;return{authorizeUrl:e,logos:x(this.getAttribute("logos")),connected:B(this,"connected"),disabled:B(this,"disabled"),variant:U(this,"variant",["default","accent","block"]),size:U(this,"size",["sm","md","lg"]),fullWidth:B(this,"full-width"),theme:U(this,"theme",["light","dark","auto"]),connectTheme:U(this,"connect-theme",["light","dark"]),openApp:null!==(t=null!==(n=this.getAttribute("open-app"))&&void 0!==n?n:this.getAttribute("connector"))&&void 0!==t?t:void 0,returnTo:null!==(o=this.getAttribute("return-to"))&&void 0!==o?o:void 0,label:null!==(i=this.getAttribute("label"))&&void 0!==i?i:void 0,connectedLabel:null!==(r=this.getAttribute("connected-label"))&&void 0!==r?r:void 0,description:null!==(a=this.getAttribute("description"))&&void 0!==a?a:void 0,accent:null!==(l=this.getAttribute("accent"))&&void 0!==l?l:void 0,accentText:null!==(s=this.getAttribute("accent-text"))&&void 0!==s?s:void 0,onSuccess:()=>{var e;null===(e=this.onSuccess)||void 0===e||e.call(this),this.dispatchEvent(new CustomEvent("success"))},onError:(e,t)=>{var n;null===(n=this.onError)||void 0===n||n.call(this,e,t),this.dispatchEvent(new CustomEvent("error",{detail:{message:e,code:t}}))},onCancel:()=>{var e;null===(e=this.onCancel)||void 0===e||e.call(this),this.dispatchEvent(new CustomEvent("cancel"))}}}sync(){const e=this.getAttribute("authorize-url");var t;if(!e)return null===(t=this.handle)||void 0===t||t.destroy(),void(this.handle=null);const n=this.props(e);this.handle?this.handle.update(n):this.handle=$(this,n)}}C(e,"observedAttributes",[...P]),customElements.define("one-connect-button",e)}}Z(),exports.createConnectFlow=h,exports.mountConnectButton=function(e,t){const n=document.createElement("span");n.className="one-connect";const o=e=>{n.setAttribute("data-variant",z(e)),n.toggleAttribute("data-full-width",Boolean(e.fullWidth))};o(t),e.appendChild(n);const i=$(n,t);return{update:e=>{o(e),i.update(e)},destroy:()=>{i.destroy(),n.remove()}}},exports.readConnectReturn=p,exports.registerConnectButton=Z,exports.renderConnectButton=$,exports.resolveVariant=z;
|
package/dist/index.esm.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
const e="one_connect",t="one_connect_error",n={declined:"You cancelled the connection.",expired:"The connection attempt expired. Please try again.",failed:"The connection could not be completed. Please try again."};function o(o){const i=new URLSearchParams(o),r=i.get(e);if("success"===r)return{status:r};if("error"!==r)return null;const a=i.get(t),l=null!==(s=a)&&Object.prototype.hasOwnProperty.call(n,s)?a:"failed";var s;return{status:r,code:l,message:n[l]}}const i=[e,t,"one_connect_message"];function r(e){const t=new URLSearchParams(e);return i.some(e=>t.has(e))}let a,l=!1,s=!1,c=!1;const d=[];function p(){return u()}function u(){return"undefined"==typeof window?null:(void 0===a&&(a=o(window.location.search),(a||r(window.location.search))&&function(){const e=()=>{r(window.location.search)&&window.history.replaceState(window.history.state,"",function(e){const t=new URLSearchParams(e.search);for(const e of i)t.delete(e);const n=t.toString();return`${e.pathname}${n?`?${n}`:""}${e.hash}`}(window.location))};e();for(const t of[50,500,2e3])window.setTimeout(e,t)}()),a)}function h(e){let t=e,n=!1;const o={deliver:e=>{try{var n,o,i,r,a,l;"success"===e.status?null===(n=(o=t).onSuccess)||void 0===n||n.call(o):null===(i=(r=t).onError)||void 0===i||i.call(r,null!==(a=e.message)&&void 0!==a?a:"",null!==(l=e.code)&&void 0!==l?l:"failed")}catch{}},restored:()=>{if(n){n=!1;try{var e,o;null===(e=(o=t).onCancel)||void 0===e||e.call(o)}catch{}}}};return"undefined"!=typeof window&&(d.push(o),c||"undefined"==typeof window||(c=!0,window.addEventListener("pageshow",e=>{if(e.persisted)for(const e of[...d])e.restored()})),function(){if(l||s)return;const e=u();e&&(s=!0,window.setTimeout(()=>{s=!1;const t=d[0];t&&!l&&(l=!0,t.deliver(e))},0))}()),{open:()=>{"undefined"!=typeof window&&(n=!0,window.location.assign((e=>{try{var t,n;const o=new URL(e.authorizeUrl,window.location.origin);e.returnTo&&o.searchParams.set("one_return_to",e.returnTo);const i=new URLSearchParams;e.connectTheme&&i.set("one_theme",e.connectTheme);const r=null===(t=null!==(n=e.openApp)&&void 0!==n?n:e.connector)||void 0===t?void 0:t.trim().toLowerCase();r&&i.set("one_open_app",r);const a=i.toString();return a&&(o.hash=a),o.toString()}catch{return e.authorizeUrl}})(t)))},update:e=>{t=e},destroy:()=>{const e=d.indexOf(o);e>=0&&d.splice(e,1)}}}function C(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}const b={"cal-com":"Cal.com","click-up":"ClickUp",clickup:"ClickUp",docusign:"DocuSign",elevenlabs:"ElevenLabs","fireflies-ai":"Fireflies.ai",github:"GitHub",gitlab:"GitLab",hubspot:"HubSpot","linked-in":"LinkedIn",linkedin:"LinkedIn","one-drive":"OneDrive",onedrive:"OneDrive",openai:"OpenAI","otter-ai":"Otter.ai",paypal:"PayPal",posthog:"PostHog",quickbooks:"QuickBooks",sharepoint:"SharePoint","spotify-web":"Spotify",teams:"Microsoft Teams","telegram-bot":"Telegram","whatsapp-business":"WhatsApp Business",woocommerce:"WooCommerce",x:"X","youtube-data":"YouTube",youtube:"YouTube"};function v(e){var t;return null!==(t=b[e])&&void 0!==t?t:e.split(/[-_]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function g(e){return e?`https://assets.withone.ai/connectors/${e}.svg`:""}function m(e){var t,n,o,i;const r="string"==typeof e?{slug:e}:e,a=null!==(t=r.slug)&&void 0!==t&&t.trim()?f(r.slug):null!==(n=r.name)&&void 0!==n&&n.trim()?f(r.name):"";return a?{slug:a,name:(null===(o=r.name)||void 0===o?void 0:o.trim())||v(a),imageUrl:(null===(i=r.imageUrl)||void 0===i?void 0:i.trim())||g(a)}:null}function x(e){const t=null==e?void 0:e.trim();if(!t)return[];if(t.startsWith("["))try{const e=JSON.parse(t);return Array.isArray(e)?e.filter(e=>"string"==typeof e||"object"==typeof e&&null!==e):[]}catch{return[]}return t.split(",").map(e=>e.trim()).filter(Boolean)}const w="#CCFF00",y="#0A0C0B",k="#FFFFFF",A=`\n:host{display:inline-block;vertical-align:middle;max-width:100%}\n:host([data-full-width]),:host([full-width]:not([full-width="false"])),\n:host([data-variant="block"]),:host([variant="block"]){display:block;width:100%}\n.b{all:unset;box-sizing:border-box;position:relative;display:inline-flex;align-items:center;gap:var(--gap);\n max-width:100%;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent;\n font-family:var(--one-connect-font,inherit);font-size:var(--fs);font-weight:500;line-height:1.2;letter-spacing:-.01em;\n padding:var(--pad);border-radius:var(--one-connect-radius,12px);background:var(--bg);color:var(--fg);\n box-shadow:var(--shadow);transition:box-shadow .2s var(--ease),background-color .2s var(--ease),opacity .2s var(--ease)}\n.b[data-full-width]{display:flex;width:100%;justify-content:center}\n.b:focus-visible{outline:2px solid var(--ring);outline-offset:2px}\n.b:hover{box-shadow:var(--shadow-hover)}\n.b[disabled]{cursor:not-allowed;opacity:.5;box-shadow:none}\n.b[aria-busy="true"]{cursor:progress}\n.b{--ease:cubic-bezier(.2,.9,.25,1)}\n.b[data-size="sm"]{--fs:13px;--pad:8px 12px 8px 10px;--gap:8px;--chip:18px;--logo:14px}\n.b[data-size="md"]{--fs:14.5px;--pad:12px 16px 12px 14px;--gap:12px;--chip:22px;--logo:16px}\n.b[data-size="lg"]{--fs:16px;--pad:14px 20px 14px 16px;--gap:12px;--chip:26px;--logo:19px}\n.b[data-theme="light"],.b[data-theme="auto"]{--ink-bg:${y};--ink-fg:${k};--surface:${k};--surface-fg:${y};\n --muted:#5B6560;--line:#D5DAD7;--ring:${y};--shadow-base:0 1px 2px rgba(10,12,11,.08),0 4px 14px rgba(10,12,11,.06);\n --shadow-strong:0 1px 2px rgba(10,12,11,.12),0 6px 18px rgba(10,12,11,.1)}\n.b[data-theme="dark"]{--ink-bg:#F2F5F3;--ink-fg:${y};--surface:#101312;--surface-fg:#F2F5F3;\n --muted:#9AA39E;--line:#2A302D;--ring:${w};--shadow-base:0 1px 2px rgba(0,0,0,.4),0 8px 24px rgba(0,0,0,.35);\n --shadow-strong:0 1px 2px rgba(0,0,0,.5),0 10px 28px rgba(0,0,0,.45)}\n@media (prefers-color-scheme:dark){.b[data-theme="auto"]{--ink-bg:#F2F5F3;--ink-fg:${y};--surface:#101312;--surface-fg:#F2F5F3;\n --muted:#9AA39E;--line:#2A302D;--ring:${w};--shadow-base:0 1px 2px rgba(0,0,0,.4),0 8px 24px rgba(0,0,0,.35);\n --shadow-strong:0 1px 2px rgba(0,0,0,.5),0 10px 28px rgba(0,0,0,.45)}}\n.b[data-variant="default"]{--bg:var(--ink-bg);--fg:var(--ink-fg);--shadow:var(--shadow-base);--shadow-hover:var(--shadow-strong)}\n.b[data-variant="accent"]{--bg:var(--one-connect-accent,${w});--fg:var(--one-connect-accent-fg,${y});\n --shadow:0 1px 2px rgba(10,12,11,.1);--shadow-hover:0 1px 2px rgba(10,12,11,.12),0 6px 18px rgba(10,12,11,.12)}\n.b[data-variant="block"]{--bg:var(--surface);--fg:var(--surface-fg);--shadow:inset 0 0 0 1px var(--line);\n --shadow-hover:inset 0 0 0 1px var(--muted);flex-direction:column;align-items:stretch;gap:0;\n width:100%;max-width:420px;text-align:left;padding:16px;border-radius:var(--one-connect-radius,14px)}\n.b[data-variant="block"][data-full-width]{max-width:none}\n.stack{display:inline-flex;align-items:center;flex-shrink:0}\n.chip{width:var(--chip);height:var(--chip);border-radius:6px;display:grid;place-items:center;overflow:hidden;\n margin-left:-7px;position:relative;background:${k};color:${y};box-shadow:0 0 0 1.5px var(--bg);\n transition:margin-left .28s var(--ease)}\n.chip:first-child{margin-left:0}\n.b[data-variant="block"] .chip{box-shadow:0 0 0 1.5px var(--bg),0 0 0 2.5px var(--line)}\n.chip img{width:var(--logo);height:var(--logo);display:block;object-fit:contain}\n.chip.more,.chip.letter{font:500 9px/1 ui-monospace,SFMono-Regular,Menlo,monospace;letter-spacing:-.02em}\n.chip.letter{font-size:10px;font-weight:600}\n.b:hover .chip{margin-left:-2px}.b:hover .chip:first-child{margin-left:0}\n.label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.icon{display:inline-flex;flex-shrink:0}\n.arrow{opacity:.55;transition:transform .2s var(--ease),opacity .2s var(--ease)}\n.b:hover .arrow{transform:translateX(2px);opacity:.85}\n.spinner{width:16px;height:16px;border-radius:50%;border:2px solid currentColor;border-top-color:transparent;\n opacity:.7;animation:spin .7s linear infinite;flex-shrink:0}\n@keyframes spin{to{transform:rotate(360deg)}}\n.top{display:flex;align-items:center;justify-content:space-between;gap:12px}\n.title{font-size:15px;font-weight:600;letter-spacing:-.01em}\n.sub{font-size:13px;line-height:1.5;margin-top:6px;font-weight:400;color:var(--muted)}\n.foot{margin-top:14px;padding-top:12px;display:flex;align-items:center;gap:6px;font-size:11px;font-weight:400;\n color:var(--muted);border-top:1px solid var(--line)}\n.lockup{display:inline-flex;color:var(--surface-fg)}\n.sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}\n@media (prefers-reduced-motion:reduce){.b,.chip,.arrow{transition:none}.spinner{animation-duration:1.6s}}\n@media (forced-colors:active){.b{border:1px solid ButtonText}.b:focus-visible{outline-color:Highlight}}\n`;let S=null;const L=(e,t,n)=>{const o=document.createElement(e);return t&&(o.className=t),void 0!==n&&(o.textContent=n),o},E=(e,t="icon")=>{const n=L("span",t);return n.innerHTML=e,n};function T(e){const t=(null!=(n=e.logos)?n:[]).map(m).filter(e=>null!==e);var n;if(0===t.length)return null;const o=L("span","stack");o.setAttribute("aria-hidden","true");for(const e of t.slice(0,3)){const t=L("span","chip");t.title=e.name;const n=L("img");n.alt="",n.decoding="async",n.src=e.imageUrl,n.addEventListener("error",()=>{n.remove(),t.classList.add("letter"),t.textContent=e.name.charAt(0).toUpperCase()}),t.appendChild(n),o.appendChild(t)}const i=t.length-3;return i>0&&o.appendChild(L("span","chip more",`+${i}`)),o}const z=e=>{var t;return null!==(t=e.variant)&&void 0!==t?t:e.accent?"accent":"default"};function F(e,t){var n,o;const i=null===(n=t.accent)||void 0===n?void 0:n.trim(),r=(null===(o=t.accentText)||void 0===o?void 0:o.trim())||(i?function(e){const t=e.trim().replace(/^#/,""),n=3===t.length?t.split("").map(e=>e+e).join(""):t;if(!/^[0-9a-f]{6}$/i.test(n))return null;const o=e=>{const t=parseInt(n.slice(e,e+2),16)/255;return t<=.03928?t/12.92:((t+.055)/1.055)**2.4},i=.2126*o(0)+.7152*o(2)+.0722*o(4);return(i+.05)/(.0037+.05)>=1.05/(i+.05)?y:k}(i):null);i?e.style.setProperty("--one-connect-accent",i):e.style.removeProperty("--one-connect-accent"),r?e.style.setProperty("--one-connect-accent-fg",r):e.style.removeProperty("--one-connect-accent-fg"),e.getAttribute("style")||e.removeAttribute("style")}const M=(e,t)=>{var n;return{authorizeUrl:e.authorizeUrl,connectTheme:e.connectTheme,openApp:null!==(n=e.openApp)&&void 0!==n?n:e.connector,returnTo:e.returnTo,...t}};function $(e,t){var n;const o=null!==(n=e.shadowRoot)&&void 0!==n?n:e.attachShadow({mode:"open"});!function(e){if("undefined"!=typeof CSSStyleSheet&&"replaceSync"in CSSStyleSheet.prototype&&"adoptedStyleSheets"in e)try{return S||(S=new CSSStyleSheet,S.replaceSync(A)),void(e.adoptedStyleSheets=[S])}catch{}const t=document.createElement("style");t.textContent=A,e.appendChild(t)}(o);let i=t,r=!1,a=!1,l=null;const s=L("button","b");s.type="button",s.setAttribute("part","button");const c=L("span","sr");c.setAttribute("role","status"),c.setAttribute("aria-live","polite"),o.append(s,c);const d=()=>{return r?"connecting":void 0!==i.connected?i.connected?"connected":"idle":"success"===(null===(e=p())||void 0===e?void 0:e.status)?"connected":"idle";var e},u={onSuccess:()=>{var e,t;return null===(e=(t=i).onSuccess)||void 0===e?void 0:e.call(t)},onError:(e,t)=>{var n,o;return null===(n=(o=i).onError)||void 0===n?void 0:n.call(o,e,t)},onCancel:()=>{var e,t;r=!1,f(),null===(e=(t=i).onCancel)||void 0===e||e.call(t)}},C=h(M(i,u)),f=()=>{var e,t,n,o;if(a)return;const r=d(),p=z(i),u="connecting"===r?"Connecting…":"connected"===r?null!==(e=i.connectedLabel)&&void 0!==e?e:"Connected":null!==(t=i.label)&&void 0!==t?t:"Connect your apps";s.dataset.variant=p,F(s,i),s.dataset.size=null!==(n=i.size)&&void 0!==n?n:"md",s.dataset.theme=null!==(o=i.theme)&&void 0!==o?o:"light",s.dataset.state=r,s.toggleAttribute("data-full-width",Boolean(i.fullWidth)),s.disabled=Boolean(i.disabled),s.setAttribute("aria-busy",String("connecting"===r)),"connecting"===r?s.setAttribute("aria-disabled","true"):s.removeAttribute("aria-disabled");const h="idle"===r?T(i):null,C="connecting"===r?L("span","spinner"):"connected"===r?E('<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M3 8.5l3.5 3.5L13 5"/></svg>'):h;if(s.replaceChildren(),s.removeAttribute("aria-labelledby"),s.removeAttribute("aria-describedby"),"block"===p){const e=L("span","top"),t=L("span","title",u);if(t.id="one-connect-title",t.setAttribute("part","label"),e.appendChild(t),C&&e.appendChild(C),s.appendChild(e),s.setAttribute("aria-labelledby",t.id),i.description){const e=L("span","sub",i.description);e.id="one-connect-description",s.appendChild(e),s.setAttribute("aria-describedby",e.id)}const n=L("span","foot");n.setAttribute("aria-hidden","true"),n.append(L("span","","Secured by"),E('<svg viewBox="0 0 3152 990" width="35" height="11" fill="none" aria-hidden="true" focusable="false"><path d="M1698.02 793.203C1525.75 793.203 1401 666.834 1401 495.102C1401 323.909 1524.67 197 1698.02 197C1870.83 197 1996.12 323.909 1996.12 495.102C1996.12 666.834 1869.75 793.203 1698.02 793.203ZM1698.02 694.916C1801.71 694.916 1884.88 615.53 1884.88 495.102C1884.88 374.133 1801.71 295.827 1698.02 295.827C1594.87 295.827 1511.71 373.053 1511.71 495.102C1511.71 616.61 1595.41 694.916 1698.02 694.916Z" fill="currentColor"/><path d="M2326.71 197.54C2480.62 197.54 2565.95 289.887 2565.95 467.56V779.702H2455.24V468.64C2455.24 361.172 2411.5 292.587 2308.35 292.587C2217.63 292.587 2140.4 356.852 2140.4 484.841V779.702H2030.77V211.041H2140.4V272.065C2185.76 225.082 2248.41 197.54 2326.71 197.54Z" fill="currentColor"/><path d="M3151.98 493.481C3151.98 514.003 3150.36 520.483 3148.74 529.124H2700.51C2715.63 637.672 2794.47 686.815 2922.46 686.815C3031.01 686.815 3099.6 650.633 3116.88 643.072V747.84C3100.68 755.4 3023.45 793.203 2908.96 793.203C2699.97 793.203 2588.18 661.434 2588.18 497.802C2588.18 332.55 2702.67 197 2871.7 197C3031.55 197 3151.98 317.969 3151.98 493.481ZM2876.02 300.688C2784.75 300.688 2720.49 345.511 2702.67 434.617H3050.45C3034.79 344.971 2967.29 300.688 2876.02 300.688Z" fill="currentColor"/><path d="M537.494 782.175C641.011 827.7 767.922 858.83 880.501 839.875C983.155 822.599 1069.64 764.946 1094.39 659.271C1114.47 573.493 1088.54 481.273 1047.27 405.311C983.124 287.246 874.768 183.791 759.847 114.657C644.926 45.5225 507.181 -5.02605 372.102 0.398669C289.698 3.69665 205.938 26.536 146.544 85.6685C112.069 119.989 88.3818 171.231 83.1266 219.823C78.1642 265.64 84.3749 310.317 99.8478 354.007C168.243 547.14 354.009 701.467 537.51 782.191L537.494 782.175ZM751.956 818.053C583.05 796.2 415.7 707.108 292.472 593.004C222.536 528.246 159.366 444.979 125.985 355.471C102.961 293.734 96.3956 223.367 122.41 161.969C137.158 127.14 160.367 98.244 190.743 75.9133C275.581 13.5752 395.819 6.99464 495.977 26.8596C608.848 49.252 713.875 99.4615 806.712 166.515C907.085 239.025 999.537 339.922 1048.42 454.627C1072.45 511.001 1083.99 570.103 1075.64 630.869C1067.38 690.957 1034.57 742.353 983.987 775.379C917.626 818.715 830.861 828.255 751.972 818.053H751.956Z" fill="currentColor"/><path d="M1103.27 661.228C1086.68 755.313 1024.9 818.622 934.021 848.69C821.751 885.846 685.146 860.263 576.251 818.915C452.515 771.942 340.336 699.91 245.157 607.813C209.002 572.83 177.255 534.456 148.837 493.031C100.384 422.402 61.7024 335.19 65.8326 248.071C68.2213 197.769 83.987 159.241 111.403 116.938C45.8289 171.308 31.404 262.511 47.1543 342.002C53.4728 373.841 62.9815 403.23 76.528 432.958C100.338 485.202 130.914 532.992 167.747 577.238C255.452 682.573 367.83 765.13 491.073 824.124C614.317 883.118 769.307 920.691 900.471 889.128C985.788 868.601 1061.47 816.095 1090.83 730.856C1098.18 708.71 1104.61 686.564 1103.25 661.244L1103.27 661.228Z" fill="currentColor"/><path d="M883.297 963.502C923.15 947.074 960.877 926.022 988.309 893.967C954.265 917.839 920.931 934.807 882.403 944.993C751.747 979.53 595.123 942.589 474.731 886.57C422.102 862.082 372.617 834.018 325.181 800.591C205.128 715.984 89.4825 597.996 36.7762 458.756C20.2092 414.973 11.7793 370.404 11.5327 323.739C11.4249 302.641 15.4627 283.747 19.0226 263.004C-2.52219 310.486 -3.66265 380.915 5.21419 431.617C32.0605 584.881 147.151 721.146 266.988 813.983C343.443 873.224 436.403 924.913 528.424 954.672C620.444 984.431 713.851 999.426 808.491 983.598C834.459 979.252 858.362 973.781 883.297 963.502Z" fill="currentColor"/><path d="M1045.09 830.737C1053.55 816.158 1061.75 802.95 1066.99 787.061C1043.75 824.541 1013.3 854.408 974.29 874.982C947.752 888.991 920.228 899.27 890.577 905.219C864.578 910.428 839.673 914.481 812.781 914.851C739.716 915.852 668.717 903.092 599.459 880.854C418.686 822.8 238.422 697.6 127.985 543.165C94.8819 496.87 68.8679 447.847 50.7135 394.031C28.1978 324.45 25.7782 258.69 53.4104 189.078C36.1345 211.825 26.9956 237.793 20.4151 264.916C18.3654 282.732 14.713 299.345 15.0828 317.561C15.9613 360.774 23.5436 402.692 38.477 443.562C73.1522 538.464 134.936 621.869 207.368 691.913C307.34 788.587 426.762 862.268 558.127 907.993C689.491 953.718 871.975 973.768 992.614 885.446C1013.28 870.312 1029.39 851.773 1045.07 830.752L1045.09 830.737Z" fill="currentColor"/><path d="M552.552 745.664C671.079 797.831 835.825 835.526 954.768 769.12C999.137 744.354 1031.99 705.626 1047.99 657.312C1086.75 540.264 1020.28 405.817 947.124 315.631C855.536 202.745 729.688 114.516 592.76 66.0323C506.349 35.4412 418.968 22.0797 328.211 37.46C262.313 48.6177 195.29 81.7054 157.563 138.234C118.912 196.133 115.891 270.785 136.758 335.882C176.519 459.926 276.769 570.763 381.01 646.277C434.995 685.391 491.662 718.864 552.567 745.664H552.552ZM210.162 422.955C199.898 402.381 189.141 382.701 184.733 360.385C182.267 347.918 184.625 333.477 184.564 320.64C184.44 293.223 194.072 269.059 209.992 247.93C219.609 235.17 229.456 224.844 243.018 215.906C341.218 151.179 476.051 175.991 576.763 223.904C661.971 264.435 737.394 321.534 796.11 395.862C836.919 447.52 871.193 513.634 880.502 579.501C888.238 634.272 873.243 695.485 826.763 729.189C807.853 742.905 785.045 751.721 761.728 755.974C721.921 763.217 688.802 758.008 649.565 748.916C594.27 736.094 542.488 715.212 492.279 688.889C441.977 662.521 396.745 631.483 353.008 595.436C314.372 563.597 280.252 537.845 248.458 498.007L248.274 497.837L221.504 461.945L211.379 445.84C194.103 418.408 177.398 391.346 165.238 361.202C151.291 326.604 142.676 291.852 143.678 254.279C146.19 160.564 203.766 96.7467 290.238 67.82C434.394 19.5985 611.561 79.4246 735.298 157.636C825.099 214.411 904.435 286.581 963.321 375.134C989.767 414.894 1010.42 456.998 1023.78 502.646C1049.84 591.66 1036.79 685.884 957.404 742.659C890.257 790.68 785.6 793.146 707.295 776.486C680.403 769.736 654.065 766.007 629.222 754.818C732.107 783.93 882.397 797.723 963.938 715.35C990.599 688.412 1007.55 656.218 1013.75 618.537C1020.87 575.232 1016.12 531.634 1002.62 489.931C985.498 437.071 956.34 384.026 922.405 340.289C876.911 281.665 823.188 230.531 762.468 187.981C681.112 130.975 588.783 88.887 490.799 71.0872C425.595 59.2514 349.463 60.4072 287.557 85.0959C256.441 97.5019 228.501 114.5 205.924 138.85C158.303 190.2 147.176 256.036 161.539 323.383C166.856 348.334 175.456 371.296 185.596 394.737C194.488 415.295 222.676 461.883 236.022 477.649L226.729 456.196L210.162 423.001V422.955ZM832.342 286.936C756.904 211.544 666.44 154.076 564.896 120.249C526.553 107.473 487.948 99.4899 447.648 96.084C401.26 92.1696 356.167 96.7313 312.215 111.341C222.337 141.208 169.399 217.277 175.255 312.333C177.567 324.847 179.555 335.774 180.603 348.503C152.971 264.944 174.454 175.236 251.356 125.581C310.797 87.2072 387.39 78.2071 456.694 86.7603C503.714 92.5549 555.387 106.656 599.078 124.317C706.016 167.546 800.764 234.615 876.741 321.395C912.002 361.664 942.085 405.756 963.876 454.532C996.779 528.166 1011.85 610.046 965.895 681.369C952.379 702.359 935.427 718.818 914.283 731.871C884.432 747.421 852.947 758.671 818.872 761.06C839.523 755.959 859.404 750.981 878.637 740.424C929.186 717.061 964.601 671.567 974.818 616.488C987.671 547.245 964.693 475.429 930.881 415.357C903.834 367.305 871.471 326.049 832.311 286.905L832.342 286.936ZM890.673 420.18C861.623 370.387 825.515 327.621 783.288 287.999C721.659 230.161 650.028 185.345 570.598 156.033C513.623 135.013 454.506 124.394 393.786 128.108C353.316 130.59 315.728 139.867 280.498 159.516C245.268 179.166 216.819 204.918 201.023 240.394L188.617 268.242C204.583 180.445 278.325 132.054 361.931 119.355C412.757 111.634 462.658 116.643 512.421 129.048C596.905 150.116 674.1 189.923 743.45 242.028C816.607 296.999 885.526 373.531 924.578 456.982C949.713 510.675 965.094 571.61 949.837 630.234C939.018 671.768 912.511 706.566 875.308 727.987C847.013 744.292 816.191 754.679 783.242 758.101C825.915 745.926 863.75 731.917 895.327 698.799C913.512 679.72 926.535 657.62 933.054 631.714C951.347 558.989 927.49 483.274 890.642 420.134L890.673 420.18ZM726.19 279.369C625.678 198.799 493.404 141.917 362.655 156.973C343.854 159.131 326.547 164.17 308.639 169.195C301.18 171.29 295.201 177.732 286.493 176.253C378.313 130.081 492.063 149.545 583.143 188.119C684.102 230.87 775.952 302.825 840.664 391.069C871.794 433.527 895.805 479.652 909.506 530.386C918.382 563.273 920.232 596.654 911.941 629.294C905.622 654.153 895.481 677.778 875.786 694.9C893.987 666.327 905.452 637.693 907.086 604.128C908.72 570.562 903.141 536.565 891.567 503.57C861.392 417.53 797.066 336.19 726.205 279.384L726.19 279.369Z" fill="currentColor"/></svg>',"lockup")),s.appendChild(n)}else{C&&s.appendChild(C);const e=L("span","label",u);e.setAttribute("part","label"),s.appendChild(e),"idle"===r&&s.appendChild(E('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M6 3l5 5-5 5"/></svg>',"icon arrow"))}var f,b;f=r,null!==l?f!==l&&(l=f,c.textContent="connecting"===f?"Connecting to One…":"connected"===f?null!==(b=i.connectedLabel)&&void 0!==b?b:"Connected":""):l=f};return s.addEventListener("click",()=>{a||i.disabled||r||(r=!0,f(),C.open())}),f(),{update:e=>{i=e,C.update(M(i,u)),f()},destroy:()=>{a=!0,C.destroy(),o.replaceChildren()}}}function P(e,t){const n=document.createElement("span");n.className="one-connect";const o=e=>{n.setAttribute("data-variant",z(e)),n.toggleAttribute("data-full-width",Boolean(e.fullWidth))};o(t),e.appendChild(n);const i=$(n,t);return{update:e=>{o(e),i.update(e)},destroy:()=>{i.destroy(),n.remove()}}}const U=["authorize-url","logos","connected","disabled","variant","size","full-width","theme","connect-theme","open-app","connector","return-to","label","connected-label","description","accent","accent-text"];function Z(e,t,n){const o=e.getAttribute(t);return o&&n.includes(o)?o:void 0}const B=(e,t)=>e.hasAttribute(t)?"false"!==e.getAttribute(t):void 0;function H(){if("undefined"!=typeof window&&"undefined"!=typeof customElements&&!customElements.get("one-connect-button")){class e extends HTMLElement{constructor(...e){super(...e),C(this,"onSuccess",null),C(this,"onError",null),C(this,"onCancel",null),C(this,"handle",null)}connectedCallback(){this.sync()}disconnectedCallback(){var e;null===(e=this.handle)||void 0===e||e.destroy(),this.handle=null}attributeChangedCallback(){this.isConnected&&this.sync()}props(e){var t,n,o,i,r,a,l,s;return{authorizeUrl:e,logos:x(this.getAttribute("logos")),connected:B(this,"connected"),disabled:B(this,"disabled"),variant:Z(this,"variant",["default","accent","block"]),size:Z(this,"size",["sm","md","lg"]),fullWidth:B(this,"full-width"),theme:Z(this,"theme",["light","dark","auto"]),connectTheme:Z(this,"connect-theme",["light","dark"]),openApp:null!==(t=null!==(n=this.getAttribute("open-app"))&&void 0!==n?n:this.getAttribute("connector"))&&void 0!==t?t:void 0,returnTo:null!==(o=this.getAttribute("return-to"))&&void 0!==o?o:void 0,label:null!==(i=this.getAttribute("label"))&&void 0!==i?i:void 0,connectedLabel:null!==(r=this.getAttribute("connected-label"))&&void 0!==r?r:void 0,description:null!==(a=this.getAttribute("description"))&&void 0!==a?a:void 0,accent:null!==(l=this.getAttribute("accent"))&&void 0!==l?l:void 0,accentText:null!==(s=this.getAttribute("accent-text"))&&void 0!==s?s:void 0,onSuccess:()=>{var e;null===(e=this.onSuccess)||void 0===e||e.call(this),this.dispatchEvent(new CustomEvent("success"))},onError:(e,t)=>{var n;null===(n=this.onError)||void 0===n||n.call(this,e,t),this.dispatchEvent(new CustomEvent("error",{detail:{message:e,code:t}}))},onCancel:()=>{var e;null===(e=this.onCancel)||void 0===e||e.call(this),this.dispatchEvent(new CustomEvent("cancel"))}}}sync(){const e=this.getAttribute("authorize-url");var t;if(!e)return null===(t=this.handle)||void 0===t||t.destroy(),void(this.handle=null);const n=this.props(e);this.handle?this.handle.update(n):this.handle=$(this,n)}}C(e,"observedAttributes",[...U]),customElements.define("one-connect-button",e)}}H();export{h as createConnectFlow,P as mountConnectButton,p as readConnectReturn,H as registerConnectButton,$ as renderConnectButton,z as resolveVariant};
|
|
1
|
+
const e="one_connect",t="one_connect_error",n={declined:"You cancelled the connection.",expired:"The connection attempt expired. Please try again.",failed:"The connection could not be completed. Please try again."};function o(o){const i=new URLSearchParams(o),r=i.get(e);if("success"===r)return{status:r};if("error"!==r)return null;const a=i.get(t),l=null!==(s=a)&&Object.prototype.hasOwnProperty.call(n,s)?a:"failed";var s;return{status:r,code:l,message:n[l]}}const i=[e,t,"one_connect_message"];function r(e){const t=new URLSearchParams(e);return i.some(e=>t.has(e))}let a,l=!1,s=!1,c=!1;const d=[];function p(){return u()}function u(){return"undefined"==typeof window?null:(void 0===a&&(a=o(window.location.search),(a||r(window.location.search))&&function(){const e=()=>{r(window.location.search)&&window.history.replaceState(window.history.state,"",function(e){const t=new URLSearchParams(e.search);for(const e of i)t.delete(e);const n=t.toString();return`${e.pathname}${n?`?${n}`:""}${e.hash}`}(window.location))};e();for(const t of[50,500,2e3])window.setTimeout(e,t)}()),a)}function h(e){let t=e,n=!1;const o={deliver:e=>{try{var n,o,i,r,a,l;"success"===e.status?null===(n=(o=t).onSuccess)||void 0===n||n.call(o):null===(i=(r=t).onError)||void 0===i||i.call(r,null!==(a=e.message)&&void 0!==a?a:"",null!==(l=e.code)&&void 0!==l?l:"failed")}catch{}},restored:()=>{if(n){n=!1;try{var e,o;null===(e=(o=t).onCancel)||void 0===e||e.call(o)}catch{}}}};return"undefined"!=typeof window&&(d.push(o),c||"undefined"==typeof window||(c=!0,window.addEventListener("pageshow",e=>{if(e.persisted)for(const e of[...d])e.restored()})),function(){if(l||s)return;const e=u();e&&(s=!0,window.setTimeout(()=>{s=!1;const t=d[0];t&&!l&&(l=!0,t.deliver(e))},0))}()),{open:()=>{"undefined"!=typeof window&&(n=!0,window.location.assign((e=>{try{var t,n;const o=new URL(e.authorizeUrl,window.location.origin);e.returnTo&&o.searchParams.set("one_return_to",e.returnTo);const i=new URLSearchParams;e.connectTheme&&i.set("one_theme",e.connectTheme);const r=null===(t=null!==(n=e.openApp)&&void 0!==n?n:e.connector)||void 0===t?void 0:t.trim().toLowerCase();r&&i.set("one_open_app",r);const a=i.toString();return a&&(o.hash=a),o.toString()}catch{return e.authorizeUrl}})(t)))},update:e=>{t=e},destroy:()=>{const e=d.indexOf(o);e>=0&&d.splice(e,1)}}}function C(e,t,n){return(t=function(e){var t=function(e,t){if("object"!=typeof e||!e)return e;var n=e[Symbol.toPrimitive];if(void 0!==n){var o=n.call(e,t);if("object"!=typeof o)return o;throw new TypeError("@@toPrimitive must return a primitive value.")}return("string"===t?String:Number)(e)}(e,"string");return"symbol"==typeof t?t:t+""}(t))in e?Object.defineProperty(e,t,{value:n,enumerable:!0,configurable:!0,writable:!0}):e[t]=n,e}function f(e){return e.trim().toLowerCase().replace(/[^a-z0-9]+/g,"-").replace(/^-+|-+$/g,"")}const b={"cal-com":"Cal.com","click-up":"ClickUp",clickup:"ClickUp",docusign:"DocuSign",elevenlabs:"ElevenLabs","fireflies-ai":"Fireflies.ai",github:"GitHub",gitlab:"GitLab",hubspot:"HubSpot","linked-in":"LinkedIn",linkedin:"LinkedIn","one-drive":"OneDrive",onedrive:"OneDrive",openai:"OpenAI","otter-ai":"Otter.ai",paypal:"PayPal",posthog:"PostHog",quickbooks:"QuickBooks",sharepoint:"SharePoint","spotify-web":"Spotify",teams:"Microsoft Teams","telegram-bot":"Telegram","whatsapp-business":"WhatsApp Business",woocommerce:"WooCommerce",x:"X","youtube-data":"YouTube",youtube:"YouTube"};function v(e){var t;return null!==(t=b[e])&&void 0!==t?t:e.split(/[-_]+/).filter(Boolean).map(e=>e.charAt(0).toUpperCase()+e.slice(1)).join(" ")}function g(e){return e?`https://assets.withone.ai/connectors/${e}.svg`:""}function m(e){var t,n,o,i;const r="string"==typeof e?{slug:e}:e,a=null!==(t=r.slug)&&void 0!==t&&t.trim()?f(r.slug):null!==(n=r.name)&&void 0!==n&&n.trim()?f(r.name):"";return a?{slug:a,name:(null===(o=r.name)||void 0===o?void 0:o.trim())||v(a),imageUrl:(null===(i=r.imageUrl)||void 0===i?void 0:i.trim())||g(a)}:null}function x(e){const t=null==e?void 0:e.trim();if(!t)return[];if(t.startsWith("["))try{const e=JSON.parse(t);return Array.isArray(e)?e.filter(e=>"string"==typeof e||"object"==typeof e&&null!==e):[]}catch{return[]}return t.split(",").map(e=>e.trim()).filter(Boolean)}const w="#CCFF00",y="#0A0C0B",k="#FFFFFF",A=`\n:host{display:inline-block;vertical-align:middle;max-width:100%}\n:host([data-full-width]),:host([full-width]:not([full-width="false"])),\n:host([data-variant="block"]),:host([variant="block"]){display:block;width:100%}\n.b{all:unset;box-sizing:border-box;position:relative;display:inline-flex;align-items:center;gap:var(--gap);\n max-width:100%;cursor:pointer;user-select:none;-webkit-tap-highlight-color:transparent;\n font-family:var(--one-connect-font,inherit);font-size:var(--fs);font-weight:500;line-height:1.2;letter-spacing:-.01em;\n padding:var(--pad);border-radius:var(--one-connect-radius,12px);background:var(--bg);color:var(--fg);\n box-shadow:var(--shadow);transition:box-shadow .2s var(--ease),background-color .2s var(--ease),opacity .2s var(--ease)}\n.b[data-full-width]{display:flex;width:100%;justify-content:center}\n.b:focus-visible{outline:2px solid var(--ring);outline-offset:2px}\n.b:hover{box-shadow:var(--shadow-hover)}\n.b[disabled]{cursor:not-allowed;opacity:.5;box-shadow:none}\n.b[aria-busy="true"]{cursor:progress}\n.b{--ease:cubic-bezier(.2,.9,.25,1)}\n.b[data-size="sm"]{--fs:13px;--pad:8px 12px 8px 10px;--gap:8px;--chip:18px;--logo:14px}\n.b[data-size="md"]{--fs:14.5px;--pad:12px 16px 12px 14px;--gap:12px;--chip:22px;--logo:16px}\n.b[data-size="lg"]{--fs:16px;--pad:14px 20px 14px 16px;--gap:12px;--chip:26px;--logo:19px}\n.b[data-theme="light"],.b[data-theme="auto"]{--ink-bg:${y};--ink-fg:${k};--surface:${k};--surface-fg:${y};\n --muted:#5B6560;--line:#D5DAD7;--ring:${y};--shadow-base:0 1px 2px rgba(10,12,11,.08),0 4px 14px rgba(10,12,11,.06);\n --shadow-strong:0 1px 2px rgba(10,12,11,.12),0 6px 18px rgba(10,12,11,.1)}\n.b[data-theme="dark"]{--ink-bg:#F2F5F3;--ink-fg:${y};--surface:#101312;--surface-fg:#F2F5F3;\n --muted:#9AA39E;--line:#2A302D;--ring:${w};--shadow-base:0 1px 2px rgba(0,0,0,.4),0 8px 24px rgba(0,0,0,.35);\n --shadow-strong:0 1px 2px rgba(0,0,0,.5),0 10px 28px rgba(0,0,0,.45)}\n@media (prefers-color-scheme:dark){.b[data-theme="auto"]{--ink-bg:#F2F5F3;--ink-fg:${y};--surface:#101312;--surface-fg:#F2F5F3;\n --muted:#9AA39E;--line:#2A302D;--ring:${w};--shadow-base:0 1px 2px rgba(0,0,0,.4),0 8px 24px rgba(0,0,0,.35);\n --shadow-strong:0 1px 2px rgba(0,0,0,.5),0 10px 28px rgba(0,0,0,.45)}}\n.b[data-variant="default"]{--bg:var(--ink-bg);--fg:var(--ink-fg);--shadow:var(--shadow-base);--shadow-hover:var(--shadow-strong)}\n.b[data-variant="accent"]{--bg:var(--one-connect-accent,${w});--fg:var(--one-connect-accent-fg,${y});\n --shadow:0 1px 2px rgba(10,12,11,.1);--shadow-hover:0 1px 2px rgba(10,12,11,.12),0 6px 18px rgba(10,12,11,.12)}\n.b[data-variant="block"]{--bg:var(--surface);--fg:var(--surface-fg);--shadow:inset 0 0 0 1px var(--line);\n --shadow-hover:inset 0 0 0 1px var(--muted);flex-direction:column;align-items:stretch;gap:0;\n width:100%;max-width:420px;text-align:left;padding:16px;border-radius:var(--one-connect-radius,14px)}\n.b[data-variant="block"][data-full-width]{max-width:none}\n.stack{display:inline-flex;align-items:center;flex-shrink:0}\n.chip{width:var(--chip);height:var(--chip);border-radius:6px;display:grid;place-items:center;overflow:hidden;\n margin-left:-7px;position:relative;background:${k};color:${y};box-shadow:0 0 0 1.5px var(--bg);\n transition:margin-left .28s var(--ease)}\n.chip:first-child{margin-left:0}\n.b[data-variant="block"] .chip{box-shadow:0 0 0 1.5px var(--bg),0 0 0 2.5px var(--line)}\n.chip img{width:var(--logo);height:var(--logo);display:block;object-fit:contain}\n.chip.more,.chip.letter{font:500 9px/1 ui-monospace,SFMono-Regular,Menlo,monospace;letter-spacing:-.02em}\n.chip.letter{font-size:10px;font-weight:600}\n.b:hover .chip{margin-left:-2px}.b:hover .chip:first-child{margin-left:0}\n.label{white-space:nowrap;overflow:hidden;text-overflow:ellipsis}\n.icon{display:inline-flex;flex-shrink:0}\n.arrow{opacity:.55;transition:transform .2s var(--ease),opacity .2s var(--ease)}\n.b:hover .arrow{transform:translateX(2px);opacity:.85}\n.spinner{width:16px;height:16px;border-radius:50%;border:2px solid currentColor;border-top-color:transparent;\n opacity:.7;animation:spin .7s linear infinite;flex-shrink:0}\n@keyframes spin{to{transform:rotate(360deg)}}\n.top{display:flex;align-items:center;justify-content:space-between;gap:12px}\n.title{font-size:15px;font-weight:600;letter-spacing:-.01em}\n.sub{font-size:13px;line-height:1.5;margin-top:6px;font-weight:400;color:var(--muted)}\n.foot{margin-top:14px;padding-top:12px;display:flex;align-items:center;gap:6px;font-size:11px;font-weight:400;\n color:var(--muted);border-top:1px solid var(--line)}\n.lockup{display:inline-flex;color:var(--surface-fg)}\n.sr{position:absolute;width:1px;height:1px;margin:-1px;padding:0;overflow:hidden;clip:rect(0 0 0 0);white-space:nowrap;border:0}\n@media (prefers-reduced-motion:reduce){.b,.chip,.arrow{transition:none}.spinner{animation-duration:1.6s}}\n@media (forced-colors:active){.b{border:1px solid ButtonText}.b:focus-visible{outline-color:Highlight}}\n`;let S=null;const L=(e,t,n)=>{const o=document.createElement(e);return t&&(o.className=t),void 0!==n&&(o.textContent=n),o},E=(e,t="icon")=>{const n=L("span",t);return n.innerHTML=e,n};function T(e){const t=(null!=(n=e.logos)?n:[]).map(m).filter(e=>null!==e);var n;if(0===t.length)return null;const o=L("span","stack");o.setAttribute("aria-hidden","true");for(const e of t.slice(0,3)){const t=L("span","chip");t.title=e.name;const n=L("img");n.alt="",n.decoding="async",n.src=e.imageUrl,n.addEventListener("error",()=>{n.remove(),t.classList.add("letter"),t.textContent=e.name.charAt(0).toUpperCase()}),t.appendChild(n),o.appendChild(t)}const i=t.length-3;return i>0&&o.appendChild(L("span","chip more",`+${i}`)),o}const z=e=>{var t;return null!==(t=e.variant)&&void 0!==t?t:e.accent?"accent":"default"};function F(e,t){var n,o;const i=null===(n=t.accent)||void 0===n?void 0:n.trim(),r=(null===(o=t.accentText)||void 0===o?void 0:o.trim())||(i?function(e){const t=e.trim().replace(/^#/,""),n=3===t.length?t.split("").map(e=>e+e).join(""):t;if(!/^[0-9a-f]{6}$/i.test(n))return null;const o=e=>(parseInt(n.slice(e,e+2),16)/255)**2.4,i=.2126729*o(0)+.7151522*o(2)+.072175*o(4);return 100*(1.14*(1-(i>.022?i:i+(.022-i)**1.414)**.65)-.027)>=45?k:y}(i):null);i?e.style.setProperty("--one-connect-accent",i):e.style.removeProperty("--one-connect-accent"),r?e.style.setProperty("--one-connect-accent-fg",r):e.style.removeProperty("--one-connect-accent-fg"),e.getAttribute("style")||e.removeAttribute("style")}const M=(e,t)=>{var n;return{authorizeUrl:e.authorizeUrl,connectTheme:e.connectTheme,openApp:null!==(n=e.openApp)&&void 0!==n?n:e.connector,returnTo:e.returnTo,...t}};function $(e,t){var n;const o=null!==(n=e.shadowRoot)&&void 0!==n?n:e.attachShadow({mode:"open"});!function(e){if("undefined"!=typeof CSSStyleSheet&&"replaceSync"in CSSStyleSheet.prototype&&"adoptedStyleSheets"in e)try{return S||(S=new CSSStyleSheet,S.replaceSync(A)),void(e.adoptedStyleSheets=[S])}catch{}const t=document.createElement("style");t.textContent=A,e.appendChild(t)}(o);let i=t,r=!1,a=!1,l=null;const s=L("button","b");s.type="button",s.setAttribute("part","button");const c=L("span","sr");c.setAttribute("role","status"),c.setAttribute("aria-live","polite"),o.append(s,c);const d=()=>{return r?"connecting":void 0!==i.connected?i.connected?"connected":"idle":"success"===(null===(e=p())||void 0===e?void 0:e.status)?"connected":"idle";var e},u={onSuccess:()=>{var e,t;return null===(e=(t=i).onSuccess)||void 0===e?void 0:e.call(t)},onError:(e,t)=>{var n,o;return null===(n=(o=i).onError)||void 0===n?void 0:n.call(o,e,t)},onCancel:()=>{var e,t;r=!1,f(),null===(e=(t=i).onCancel)||void 0===e||e.call(t)}},C=h(M(i,u)),f=()=>{var e,t,n,o;if(a)return;const r=d(),p=z(i),u="connecting"===r?"Connecting…":"connected"===r?null!==(e=i.connectedLabel)&&void 0!==e?e:"Connected":null!==(t=i.label)&&void 0!==t?t:"Connect your apps";s.dataset.variant=p,F(s,i),s.dataset.size=null!==(n=i.size)&&void 0!==n?n:"md",s.dataset.theme=null!==(o=i.theme)&&void 0!==o?o:"light",s.dataset.state=r,s.toggleAttribute("data-full-width",Boolean(i.fullWidth)),s.disabled=Boolean(i.disabled),s.setAttribute("aria-busy",String("connecting"===r)),"connecting"===r?s.setAttribute("aria-disabled","true"):s.removeAttribute("aria-disabled");const h="idle"===r?T(i):null,C="connecting"===r?L("span","spinner"):"connected"===r?E('<svg width="16" height="16" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M3 8.5l3.5 3.5L13 5"/></svg>'):h;if(s.replaceChildren(),s.removeAttribute("aria-labelledby"),s.removeAttribute("aria-describedby"),"block"===p){const e=L("span","top"),t=L("span","title",u);if(t.id="one-connect-title",t.setAttribute("part","label"),e.appendChild(t),C&&e.appendChild(C),s.appendChild(e),s.setAttribute("aria-labelledby",t.id),i.description){const e=L("span","sub",i.description);e.id="one-connect-description",s.appendChild(e),s.setAttribute("aria-describedby",e.id)}const n=L("span","foot");n.setAttribute("aria-hidden","true"),n.append(L("span","","Secured by"),E('<svg viewBox="0 0 3152 990" width="35" height="11" fill="none" aria-hidden="true" focusable="false"><path d="M1698.02 793.203C1525.75 793.203 1401 666.834 1401 495.102C1401 323.909 1524.67 197 1698.02 197C1870.83 197 1996.12 323.909 1996.12 495.102C1996.12 666.834 1869.75 793.203 1698.02 793.203ZM1698.02 694.916C1801.71 694.916 1884.88 615.53 1884.88 495.102C1884.88 374.133 1801.71 295.827 1698.02 295.827C1594.87 295.827 1511.71 373.053 1511.71 495.102C1511.71 616.61 1595.41 694.916 1698.02 694.916Z" fill="currentColor"/><path d="M2326.71 197.54C2480.62 197.54 2565.95 289.887 2565.95 467.56V779.702H2455.24V468.64C2455.24 361.172 2411.5 292.587 2308.35 292.587C2217.63 292.587 2140.4 356.852 2140.4 484.841V779.702H2030.77V211.041H2140.4V272.065C2185.76 225.082 2248.41 197.54 2326.71 197.54Z" fill="currentColor"/><path d="M3151.98 493.481C3151.98 514.003 3150.36 520.483 3148.74 529.124H2700.51C2715.63 637.672 2794.47 686.815 2922.46 686.815C3031.01 686.815 3099.6 650.633 3116.88 643.072V747.84C3100.68 755.4 3023.45 793.203 2908.96 793.203C2699.97 793.203 2588.18 661.434 2588.18 497.802C2588.18 332.55 2702.67 197 2871.7 197C3031.55 197 3151.98 317.969 3151.98 493.481ZM2876.02 300.688C2784.75 300.688 2720.49 345.511 2702.67 434.617H3050.45C3034.79 344.971 2967.29 300.688 2876.02 300.688Z" fill="currentColor"/><path d="M537.494 782.175C641.011 827.7 767.922 858.83 880.501 839.875C983.155 822.599 1069.64 764.946 1094.39 659.271C1114.47 573.493 1088.54 481.273 1047.27 405.311C983.124 287.246 874.768 183.791 759.847 114.657C644.926 45.5225 507.181 -5.02605 372.102 0.398669C289.698 3.69665 205.938 26.536 146.544 85.6685C112.069 119.989 88.3818 171.231 83.1266 219.823C78.1642 265.64 84.3749 310.317 99.8478 354.007C168.243 547.14 354.009 701.467 537.51 782.191L537.494 782.175ZM751.956 818.053C583.05 796.2 415.7 707.108 292.472 593.004C222.536 528.246 159.366 444.979 125.985 355.471C102.961 293.734 96.3956 223.367 122.41 161.969C137.158 127.14 160.367 98.244 190.743 75.9133C275.581 13.5752 395.819 6.99464 495.977 26.8596C608.848 49.252 713.875 99.4615 806.712 166.515C907.085 239.025 999.537 339.922 1048.42 454.627C1072.45 511.001 1083.99 570.103 1075.64 630.869C1067.38 690.957 1034.57 742.353 983.987 775.379C917.626 818.715 830.861 828.255 751.972 818.053H751.956Z" fill="currentColor"/><path d="M1103.27 661.228C1086.68 755.313 1024.9 818.622 934.021 848.69C821.751 885.846 685.146 860.263 576.251 818.915C452.515 771.942 340.336 699.91 245.157 607.813C209.002 572.83 177.255 534.456 148.837 493.031C100.384 422.402 61.7024 335.19 65.8326 248.071C68.2213 197.769 83.987 159.241 111.403 116.938C45.8289 171.308 31.404 262.511 47.1543 342.002C53.4728 373.841 62.9815 403.23 76.528 432.958C100.338 485.202 130.914 532.992 167.747 577.238C255.452 682.573 367.83 765.13 491.073 824.124C614.317 883.118 769.307 920.691 900.471 889.128C985.788 868.601 1061.47 816.095 1090.83 730.856C1098.18 708.71 1104.61 686.564 1103.25 661.244L1103.27 661.228Z" fill="currentColor"/><path d="M883.297 963.502C923.15 947.074 960.877 926.022 988.309 893.967C954.265 917.839 920.931 934.807 882.403 944.993C751.747 979.53 595.123 942.589 474.731 886.57C422.102 862.082 372.617 834.018 325.181 800.591C205.128 715.984 89.4825 597.996 36.7762 458.756C20.2092 414.973 11.7793 370.404 11.5327 323.739C11.4249 302.641 15.4627 283.747 19.0226 263.004C-2.52219 310.486 -3.66265 380.915 5.21419 431.617C32.0605 584.881 147.151 721.146 266.988 813.983C343.443 873.224 436.403 924.913 528.424 954.672C620.444 984.431 713.851 999.426 808.491 983.598C834.459 979.252 858.362 973.781 883.297 963.502Z" fill="currentColor"/><path d="M1045.09 830.737C1053.55 816.158 1061.75 802.95 1066.99 787.061C1043.75 824.541 1013.3 854.408 974.29 874.982C947.752 888.991 920.228 899.27 890.577 905.219C864.578 910.428 839.673 914.481 812.781 914.851C739.716 915.852 668.717 903.092 599.459 880.854C418.686 822.8 238.422 697.6 127.985 543.165C94.8819 496.87 68.8679 447.847 50.7135 394.031C28.1978 324.45 25.7782 258.69 53.4104 189.078C36.1345 211.825 26.9956 237.793 20.4151 264.916C18.3654 282.732 14.713 299.345 15.0828 317.561C15.9613 360.774 23.5436 402.692 38.477 443.562C73.1522 538.464 134.936 621.869 207.368 691.913C307.34 788.587 426.762 862.268 558.127 907.993C689.491 953.718 871.975 973.768 992.614 885.446C1013.28 870.312 1029.39 851.773 1045.07 830.752L1045.09 830.737Z" fill="currentColor"/><path d="M552.552 745.664C671.079 797.831 835.825 835.526 954.768 769.12C999.137 744.354 1031.99 705.626 1047.99 657.312C1086.75 540.264 1020.28 405.817 947.124 315.631C855.536 202.745 729.688 114.516 592.76 66.0323C506.349 35.4412 418.968 22.0797 328.211 37.46C262.313 48.6177 195.29 81.7054 157.563 138.234C118.912 196.133 115.891 270.785 136.758 335.882C176.519 459.926 276.769 570.763 381.01 646.277C434.995 685.391 491.662 718.864 552.567 745.664H552.552ZM210.162 422.955C199.898 402.381 189.141 382.701 184.733 360.385C182.267 347.918 184.625 333.477 184.564 320.64C184.44 293.223 194.072 269.059 209.992 247.93C219.609 235.17 229.456 224.844 243.018 215.906C341.218 151.179 476.051 175.991 576.763 223.904C661.971 264.435 737.394 321.534 796.11 395.862C836.919 447.52 871.193 513.634 880.502 579.501C888.238 634.272 873.243 695.485 826.763 729.189C807.853 742.905 785.045 751.721 761.728 755.974C721.921 763.217 688.802 758.008 649.565 748.916C594.27 736.094 542.488 715.212 492.279 688.889C441.977 662.521 396.745 631.483 353.008 595.436C314.372 563.597 280.252 537.845 248.458 498.007L248.274 497.837L221.504 461.945L211.379 445.84C194.103 418.408 177.398 391.346 165.238 361.202C151.291 326.604 142.676 291.852 143.678 254.279C146.19 160.564 203.766 96.7467 290.238 67.82C434.394 19.5985 611.561 79.4246 735.298 157.636C825.099 214.411 904.435 286.581 963.321 375.134C989.767 414.894 1010.42 456.998 1023.78 502.646C1049.84 591.66 1036.79 685.884 957.404 742.659C890.257 790.68 785.6 793.146 707.295 776.486C680.403 769.736 654.065 766.007 629.222 754.818C732.107 783.93 882.397 797.723 963.938 715.35C990.599 688.412 1007.55 656.218 1013.75 618.537C1020.87 575.232 1016.12 531.634 1002.62 489.931C985.498 437.071 956.34 384.026 922.405 340.289C876.911 281.665 823.188 230.531 762.468 187.981C681.112 130.975 588.783 88.887 490.799 71.0872C425.595 59.2514 349.463 60.4072 287.557 85.0959C256.441 97.5019 228.501 114.5 205.924 138.85C158.303 190.2 147.176 256.036 161.539 323.383C166.856 348.334 175.456 371.296 185.596 394.737C194.488 415.295 222.676 461.883 236.022 477.649L226.729 456.196L210.162 423.001V422.955ZM832.342 286.936C756.904 211.544 666.44 154.076 564.896 120.249C526.553 107.473 487.948 99.4899 447.648 96.084C401.26 92.1696 356.167 96.7313 312.215 111.341C222.337 141.208 169.399 217.277 175.255 312.333C177.567 324.847 179.555 335.774 180.603 348.503C152.971 264.944 174.454 175.236 251.356 125.581C310.797 87.2072 387.39 78.2071 456.694 86.7603C503.714 92.5549 555.387 106.656 599.078 124.317C706.016 167.546 800.764 234.615 876.741 321.395C912.002 361.664 942.085 405.756 963.876 454.532C996.779 528.166 1011.85 610.046 965.895 681.369C952.379 702.359 935.427 718.818 914.283 731.871C884.432 747.421 852.947 758.671 818.872 761.06C839.523 755.959 859.404 750.981 878.637 740.424C929.186 717.061 964.601 671.567 974.818 616.488C987.671 547.245 964.693 475.429 930.881 415.357C903.834 367.305 871.471 326.049 832.311 286.905L832.342 286.936ZM890.673 420.18C861.623 370.387 825.515 327.621 783.288 287.999C721.659 230.161 650.028 185.345 570.598 156.033C513.623 135.013 454.506 124.394 393.786 128.108C353.316 130.59 315.728 139.867 280.498 159.516C245.268 179.166 216.819 204.918 201.023 240.394L188.617 268.242C204.583 180.445 278.325 132.054 361.931 119.355C412.757 111.634 462.658 116.643 512.421 129.048C596.905 150.116 674.1 189.923 743.45 242.028C816.607 296.999 885.526 373.531 924.578 456.982C949.713 510.675 965.094 571.61 949.837 630.234C939.018 671.768 912.511 706.566 875.308 727.987C847.013 744.292 816.191 754.679 783.242 758.101C825.915 745.926 863.75 731.917 895.327 698.799C913.512 679.72 926.535 657.62 933.054 631.714C951.347 558.989 927.49 483.274 890.642 420.134L890.673 420.18ZM726.19 279.369C625.678 198.799 493.404 141.917 362.655 156.973C343.854 159.131 326.547 164.17 308.639 169.195C301.18 171.29 295.201 177.732 286.493 176.253C378.313 130.081 492.063 149.545 583.143 188.119C684.102 230.87 775.952 302.825 840.664 391.069C871.794 433.527 895.805 479.652 909.506 530.386C918.382 563.273 920.232 596.654 911.941 629.294C905.622 654.153 895.481 677.778 875.786 694.9C893.987 666.327 905.452 637.693 907.086 604.128C908.72 570.562 903.141 536.565 891.567 503.57C861.392 417.53 797.066 336.19 726.205 279.384L726.19 279.369Z" fill="currentColor"/></svg>',"lockup")),s.appendChild(n)}else{C&&s.appendChild(C);const e=L("span","label",u);e.setAttribute("part","label"),s.appendChild(e),"idle"===r&&s.appendChild(E('<svg width="14" height="14" viewBox="0 0 16 16" fill="none" stroke="currentColor" stroke-width="1.6" stroke-linecap="round" stroke-linejoin="round" aria-hidden="true" focusable="false"><path d="M6 3l5 5-5 5"/></svg>',"icon arrow"))}var f,b;f=r,null!==l?f!==l&&(l=f,c.textContent="connecting"===f?"Connecting to One…":"connected"===f?null!==(b=i.connectedLabel)&&void 0!==b?b:"Connected":""):l=f};return s.addEventListener("click",()=>{a||i.disabled||r||(r=!0,f(),C.open())}),f(),{update:e=>{i=e,C.update(M(i,u)),f()},destroy:()=>{a=!0,C.destroy(),o.replaceChildren()}}}function P(e,t){const n=document.createElement("span");n.className="one-connect";const o=e=>{n.setAttribute("data-variant",z(e)),n.toggleAttribute("data-full-width",Boolean(e.fullWidth))};o(t),e.appendChild(n);const i=$(n,t);return{update:e=>{o(e),i.update(e)},destroy:()=>{i.destroy(),n.remove()}}}const U=["authorize-url","logos","connected","disabled","variant","size","full-width","theme","connect-theme","open-app","connector","return-to","label","connected-label","description","accent","accent-text"];function Z(e,t,n){const o=e.getAttribute(t);return o&&n.includes(o)?o:void 0}const B=(e,t)=>e.hasAttribute(t)?"false"!==e.getAttribute(t):void 0;function H(){if("undefined"!=typeof window&&"undefined"!=typeof customElements&&!customElements.get("one-connect-button")){class e extends HTMLElement{constructor(...e){super(...e),C(this,"onSuccess",null),C(this,"onError",null),C(this,"onCancel",null),C(this,"handle",null)}connectedCallback(){this.sync()}disconnectedCallback(){var e;null===(e=this.handle)||void 0===e||e.destroy(),this.handle=null}attributeChangedCallback(){this.isConnected&&this.sync()}props(e){var t,n,o,i,r,a,l,s;return{authorizeUrl:e,logos:x(this.getAttribute("logos")),connected:B(this,"connected"),disabled:B(this,"disabled"),variant:Z(this,"variant",["default","accent","block"]),size:Z(this,"size",["sm","md","lg"]),fullWidth:B(this,"full-width"),theme:Z(this,"theme",["light","dark","auto"]),connectTheme:Z(this,"connect-theme",["light","dark"]),openApp:null!==(t=null!==(n=this.getAttribute("open-app"))&&void 0!==n?n:this.getAttribute("connector"))&&void 0!==t?t:void 0,returnTo:null!==(o=this.getAttribute("return-to"))&&void 0!==o?o:void 0,label:null!==(i=this.getAttribute("label"))&&void 0!==i?i:void 0,connectedLabel:null!==(r=this.getAttribute("connected-label"))&&void 0!==r?r:void 0,description:null!==(a=this.getAttribute("description"))&&void 0!==a?a:void 0,accent:null!==(l=this.getAttribute("accent"))&&void 0!==l?l:void 0,accentText:null!==(s=this.getAttribute("accent-text"))&&void 0!==s?s:void 0,onSuccess:()=>{var e;null===(e=this.onSuccess)||void 0===e||e.call(this),this.dispatchEvent(new CustomEvent("success"))},onError:(e,t)=>{var n;null===(n=this.onError)||void 0===n||n.call(this,e,t),this.dispatchEvent(new CustomEvent("error",{detail:{message:e,code:t}}))},onCancel:()=>{var e;null===(e=this.onCancel)||void 0===e||e.call(this),this.dispatchEvent(new CustomEvent("cancel"))}}}sync(){const e=this.getAttribute("authorize-url");var t;if(!e)return null===(t=this.handle)||void 0===t||t.destroy(),void(this.handle=null);const n=this.props(e);this.handle?this.handle.update(n):this.handle=$(this,n)}}C(e,"observedAttributes",[...U]),customElements.define("one-connect-button",e)}}H();export{h as createConnectFlow,P as mountConnectButton,p as readConnectReturn,H as registerConnectButton,$ as renderConnectButton,z as resolveVariant};
|
package/dist/server/index.cjs.js
CHANGED
|
@@ -200,6 +200,12 @@ function tokenScopes(accessToken) {
|
|
|
200
200
|
* a backoff.
|
|
201
201
|
*/
|
|
202
202
|
|
|
203
|
+
/**
|
|
204
|
+
* One's rate limit for the user a call was made for, as One reported it on
|
|
205
|
+
* that call. The app owner's plan sets the size; each of the app's users
|
|
206
|
+
* has a bucket of their own. Any value One didn't send is `null`.
|
|
207
|
+
*/
|
|
208
|
+
|
|
203
209
|
/**
|
|
204
210
|
* - `not_connected`: nothing is stored for this user.
|
|
205
211
|
* - `reconnect_required` (key mode): One will not act for this user.
|
|
@@ -542,6 +548,33 @@ function oneRefusal(response, data) {
|
|
|
542
548
|
if (response.status === 429) return "rate_limit";
|
|
543
549
|
return "one_error";
|
|
544
550
|
}
|
|
551
|
+
|
|
552
|
+
/**
|
|
553
|
+
* One's rate limit from a reply's headers, or `null` when it sent none of
|
|
554
|
+
* them. A missing or unreadable header reads `null` on its own and never
|
|
555
|
+
* throws. One writes "no limit" as the largest 64-bit integer, which
|
|
556
|
+
* reads as `null` too.
|
|
557
|
+
*/
|
|
558
|
+
function rateLimitFrom(headers) {
|
|
559
|
+
const read = name => {
|
|
560
|
+
const value = headers.get(name)?.trim();
|
|
561
|
+
if (!value) return null;
|
|
562
|
+
const number = Number(value);
|
|
563
|
+
return Number.isFinite(number) && number >= 0 ? number : null;
|
|
564
|
+
};
|
|
565
|
+
const limit = read("x-ratelimit-limit");
|
|
566
|
+
const remaining = read("x-ratelimit-remaining");
|
|
567
|
+
const resetsIn = read("x-ratelimit-reset");
|
|
568
|
+
const retryAfter = read("retry-after");
|
|
569
|
+
if (limit === null && remaining === null && resetsIn === null && retryAfter === null) return null;
|
|
570
|
+
const unlimited = limit !== null && limit > Number.MAX_SAFE_INTEGER;
|
|
571
|
+
return {
|
|
572
|
+
limit: unlimited ? null : limit,
|
|
573
|
+
remaining: unlimited ? null : remaining,
|
|
574
|
+
resetsIn,
|
|
575
|
+
retryAfter
|
|
576
|
+
};
|
|
577
|
+
}
|
|
545
578
|
const CATALOG_PAGE_SIZE = 100;
|
|
546
579
|
/** One's largest page; reading every connection takes the fewest calls. */
|
|
547
580
|
const CONNECTIONS_PAGE_SIZE = 150;
|
|
@@ -901,6 +934,7 @@ function createOneConnect(config) {
|
|
|
901
934
|
body
|
|
902
935
|
});
|
|
903
936
|
const text = await response.text();
|
|
937
|
+
const rateLimit = rateLimitFrom(response.headers);
|
|
904
938
|
if (!response.ok) {
|
|
905
939
|
const refused = credential.refusal(response.status, text);
|
|
906
940
|
if (refused?.code === "reconnect_required") {
|
|
@@ -913,6 +947,7 @@ function createOneConnect(config) {
|
|
|
913
947
|
ok: false,
|
|
914
948
|
blockedByGrant: true,
|
|
915
949
|
refusal: "grant",
|
|
950
|
+
rateLimit,
|
|
916
951
|
data: text
|
|
917
952
|
};
|
|
918
953
|
throw refused;
|
|
@@ -932,6 +967,7 @@ function createOneConnect(config) {
|
|
|
932
967
|
ok: response.ok,
|
|
933
968
|
blockedByGrant: refusal === "grant",
|
|
934
969
|
refusal,
|
|
970
|
+
rateLimit,
|
|
935
971
|
data
|
|
936
972
|
};
|
|
937
973
|
};
|
package/dist/server/index.esm.js
CHANGED
|
@@ -198,6 +198,12 @@ function tokenScopes(accessToken) {
|
|
|
198
198
|
* a backoff.
|
|
199
199
|
*/
|
|
200
200
|
|
|
201
|
+
/**
|
|
202
|
+
* One's rate limit for the user a call was made for, as One reported it on
|
|
203
|
+
* that call. The app owner's plan sets the size; each of the app's users
|
|
204
|
+
* has a bucket of their own. Any value One didn't send is `null`.
|
|
205
|
+
*/
|
|
206
|
+
|
|
201
207
|
/**
|
|
202
208
|
* - `not_connected`: nothing is stored for this user.
|
|
203
209
|
* - `reconnect_required` (key mode): One will not act for this user.
|
|
@@ -540,6 +546,33 @@ function oneRefusal(response, data) {
|
|
|
540
546
|
if (response.status === 429) return "rate_limit";
|
|
541
547
|
return "one_error";
|
|
542
548
|
}
|
|
549
|
+
|
|
550
|
+
/**
|
|
551
|
+
* One's rate limit from a reply's headers, or `null` when it sent none of
|
|
552
|
+
* them. A missing or unreadable header reads `null` on its own and never
|
|
553
|
+
* throws. One writes "no limit" as the largest 64-bit integer, which
|
|
554
|
+
* reads as `null` too.
|
|
555
|
+
*/
|
|
556
|
+
function rateLimitFrom(headers) {
|
|
557
|
+
const read = name => {
|
|
558
|
+
const value = headers.get(name)?.trim();
|
|
559
|
+
if (!value) return null;
|
|
560
|
+
const number = Number(value);
|
|
561
|
+
return Number.isFinite(number) && number >= 0 ? number : null;
|
|
562
|
+
};
|
|
563
|
+
const limit = read("x-ratelimit-limit");
|
|
564
|
+
const remaining = read("x-ratelimit-remaining");
|
|
565
|
+
const resetsIn = read("x-ratelimit-reset");
|
|
566
|
+
const retryAfter = read("retry-after");
|
|
567
|
+
if (limit === null && remaining === null && resetsIn === null && retryAfter === null) return null;
|
|
568
|
+
const unlimited = limit !== null && limit > Number.MAX_SAFE_INTEGER;
|
|
569
|
+
return {
|
|
570
|
+
limit: unlimited ? null : limit,
|
|
571
|
+
remaining: unlimited ? null : remaining,
|
|
572
|
+
resetsIn,
|
|
573
|
+
retryAfter
|
|
574
|
+
};
|
|
575
|
+
}
|
|
543
576
|
const CATALOG_PAGE_SIZE = 100;
|
|
544
577
|
/** One's largest page; reading every connection takes the fewest calls. */
|
|
545
578
|
const CONNECTIONS_PAGE_SIZE = 150;
|
|
@@ -899,6 +932,7 @@ function createOneConnect(config) {
|
|
|
899
932
|
body
|
|
900
933
|
});
|
|
901
934
|
const text = await response.text();
|
|
935
|
+
const rateLimit = rateLimitFrom(response.headers);
|
|
902
936
|
if (!response.ok) {
|
|
903
937
|
const refused = credential.refusal(response.status, text);
|
|
904
938
|
if (refused?.code === "reconnect_required") {
|
|
@@ -911,6 +945,7 @@ function createOneConnect(config) {
|
|
|
911
945
|
ok: false,
|
|
912
946
|
blockedByGrant: true,
|
|
913
947
|
refusal: "grant",
|
|
948
|
+
rateLimit,
|
|
914
949
|
data: text
|
|
915
950
|
};
|
|
916
951
|
throw refused;
|
|
@@ -930,6 +965,7 @@ function createOneConnect(config) {
|
|
|
930
965
|
ok: response.ok,
|
|
931
966
|
blockedByGrant: refusal === "grant",
|
|
932
967
|
refusal,
|
|
968
|
+
rateLimit,
|
|
933
969
|
data
|
|
934
970
|
};
|
|
935
971
|
};
|
package/dist/server/types.d.ts
CHANGED
|
@@ -281,6 +281,21 @@ export interface RunActionInput {
|
|
|
281
281
|
* a backoff.
|
|
282
282
|
*/
|
|
283
283
|
export type OneRefusal = "grant" | "plan_limit" | "rate_limit" | "one_error";
|
|
284
|
+
/**
|
|
285
|
+
* One's rate limit for the user a call was made for, as One reported it on
|
|
286
|
+
* that call. The app owner's plan sets the size; each of the app's users
|
|
287
|
+
* has a bucket of their own. Any value One didn't send is `null`.
|
|
288
|
+
*/
|
|
289
|
+
export interface RateLimit {
|
|
290
|
+
/** Calls this user may make a minute. `null` when nothing limits them. */
|
|
291
|
+
limit: number | null;
|
|
292
|
+
/** Calls left in the current minute. `null` when nothing limits them. */
|
|
293
|
+
remaining: number | null;
|
|
294
|
+
/** Seconds until the minute resets. */
|
|
295
|
+
resetsIn: number | null;
|
|
296
|
+
/** Seconds to wait before trying again. Set on a 429 only. */
|
|
297
|
+
retryAfter: number | null;
|
|
298
|
+
}
|
|
284
299
|
export interface RunActionResult {
|
|
285
300
|
status: number;
|
|
286
301
|
ok: boolean;
|
|
@@ -293,6 +308,11 @@ export interface RunActionResult {
|
|
|
293
308
|
/** Why One turned the call down, or `null` when it didn't (the call
|
|
294
309
|
* succeeded, or the provider answered with its own error). */
|
|
295
310
|
refusal: OneRefusal | null;
|
|
311
|
+
/** One's rate limit for this user after the call, or `null` when One
|
|
312
|
+
* sent none of its rate-limit headers. A `refusal` of `"plan_limit"`
|
|
313
|
+
* (402) means this user's calls for the month are used up: back off
|
|
314
|
+
* for the month, don't retry. */
|
|
315
|
+
rateLimit: RateLimit | null;
|
|
296
316
|
data: unknown;
|
|
297
317
|
}
|
|
298
318
|
/**
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@withone/connect",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"description": "One Connect for your app: the button your users press, the two backend routes as one import, and a server client that calls One with the grant. Users keep their connections in One; your app holds only what they granted.",
|
|
5
5
|
"files": [
|
|
6
6
|
"dist",
|
|
@@ -279,9 +279,13 @@ const reply = await oneConnect.runAction(userId, {
|
|
|
279
279
|
encoding: "json", // or "form" / "multipart", as the guide says
|
|
280
280
|
headers: {}, // only when the guide names one
|
|
281
281
|
});
|
|
282
|
-
// { status, ok, blockedByGrant, refusal, data }
|
|
282
|
+
// { status, ok, blockedByGrant, refusal, rateLimit, data }
|
|
283
283
|
```
|
|
284
284
|
|
|
285
|
+
`rateLimit` is `{ limit, remaining, resetsIn, retryAfter }` for that user
|
|
286
|
+
(calls per minute, seconds), or `null` when One sent none. Slow down as
|
|
287
|
+
`remaining` nears 0; on a `429` wait `retryAfter` seconds.
|
|
288
|
+
|
|
285
289
|
Each connection's `access` is `{ policy: "full" }`, `{ policy: "methods",
|
|
286
290
|
methods }` or `{ policy: "actions", actions }`; plan from it before calling.
|
|
287
291
|
`runAction` takes the method and path from the action, fills the path's
|
|
@@ -308,9 +312,11 @@ user's id to every call it makes.
|
|
|
308
312
|
|
|
309
313
|
- `"grant"` (`403`, `blockedByGrant: true`): outside what the user granted.
|
|
310
314
|
Do not retry it.
|
|
311
|
-
- `"plan_limit"` (`402`):
|
|
312
|
-
|
|
313
|
-
|
|
315
|
+
- `"plan_limit"` (`402`): the user's calls for the month are used up, not
|
|
316
|
+
the grant. Stop calling for this user until next month. Do not ask the
|
|
317
|
+
user to reconnect.
|
|
318
|
+
- `"rate_limit"` (`429`): too many calls. Wait `rateLimit.retryAfter`
|
|
319
|
+
seconds and retry.
|
|
314
320
|
- `"one_error"` (other, e.g. `5xx`): retry with a backoff.
|
|
315
321
|
- `null`: not One's refusal; the provider's own answer, or a success.
|
|
316
322
|
|
package/src/button.ts
CHANGED
|
@@ -182,9 +182,15 @@ function buildStack(props: ConnectButtonProps): HTMLElement | null {
|
|
|
182
182
|
export const resolveVariant = (props: ConnectButtonProps) =>
|
|
183
183
|
props.variant ?? (props.accent ? "accent" : "default");
|
|
184
184
|
|
|
185
|
-
/**
|
|
186
|
-
*
|
|
187
|
-
|
|
185
|
+
/** The lowest APCA contrast (Lc) at which white text still reads on the
|
|
186
|
+
* button. A fill paler than that gets dark text. */
|
|
187
|
+
const WHITE_TEXT_MIN_LC = 45;
|
|
188
|
+
|
|
189
|
+
/** White or dark text on a hex fill. White whenever it still reads, as on
|
|
190
|
+
* most brand buttons; dark only on fills pale enough to wash it out
|
|
191
|
+
* (yellow, lime, pastels). Measured with APCA, because WCAG's ratio puts
|
|
192
|
+
* black on mid-tones such as red, orange and blue. Null for anything that
|
|
193
|
+
* isn't a hex colour: the stylesheet's default stands. */
|
|
188
194
|
export function readableTextOn(fill: string): string | null {
|
|
189
195
|
const hex = fill.trim().replace(/^#/, "");
|
|
190
196
|
const full =
|
|
@@ -195,17 +201,16 @@ export function readableTextOn(fill: string): string | null {
|
|
|
195
201
|
.join("")
|
|
196
202
|
: hex;
|
|
197
203
|
if (!/^[0-9a-f]{6}$/i.test(full)) return null;
|
|
198
|
-
const channel = (i: number) =>
|
|
199
|
-
|
|
200
|
-
return v <= 0.03928 ? v / 12.92 : ((v + 0.055) / 1.055) ** 2.4;
|
|
201
|
-
};
|
|
204
|
+
const channel = (i: number) =>
|
|
205
|
+
(parseInt(full.slice(i, i + 2), 16) / 255) ** 2.4;
|
|
202
206
|
const luminance =
|
|
203
|
-
0.
|
|
204
|
-
//
|
|
205
|
-
//
|
|
206
|
-
const
|
|
207
|
-
|
|
208
|
-
|
|
207
|
+
0.2126729 * channel(0) + 0.7151522 * channel(2) + 0.072175 * channel(4);
|
|
208
|
+
// APCA (0.0.98G) for white text on the fill: soft-clamp near black, then
|
|
209
|
+
// the reverse-polarity contrast.
|
|
210
|
+
const fillY =
|
|
211
|
+
luminance > 0.022 ? luminance : luminance + (0.022 - luminance) ** 1.414;
|
|
212
|
+
const whiteLc = (1.14 * (1 - fillY ** 0.65) - 0.027) * 100;
|
|
213
|
+
return whiteLc >= WHITE_TEXT_MIN_LC ? WHITE : CARBON;
|
|
209
214
|
}
|
|
210
215
|
|
|
211
216
|
/** Brand colours from props, set on the button through the CSSOM (which
|
package/src/server/index.ts
CHANGED
|
@@ -29,7 +29,11 @@
|
|
|
29
29
|
* The Next.js and Node adapters turn the first two into route handlers.
|
|
30
30
|
* See `./key` and `./token` for what each mode stores and sends.
|
|
31
31
|
*/
|
|
32
|
-
import {
|
|
32
|
+
import {
|
|
33
|
+
DEFAULT_ONE_API_URL,
|
|
34
|
+
RETURN_ERROR_PARAM,
|
|
35
|
+
RETURN_STATUS_PARAM,
|
|
36
|
+
} from "../constants";
|
|
33
37
|
import type { Credential, PostToken, TokenResponse } from "./credential";
|
|
34
38
|
import { createKeyCredential } from "./key";
|
|
35
39
|
import {
|
|
@@ -61,6 +65,7 @@ import {
|
|
|
61
65
|
type RefreshIfExpiringOptions,
|
|
62
66
|
type RunActionInput,
|
|
63
67
|
type OneRefusal,
|
|
68
|
+
type RateLimit,
|
|
64
69
|
type RunActionResult,
|
|
65
70
|
type SearchActionsOptions,
|
|
66
71
|
type StartAuthorizationInput,
|
|
@@ -81,7 +86,9 @@ export { refreshTokenExpiresAt, tenancyHeaders, tokenScopes } from "./oauth";
|
|
|
81
86
|
function oneRefusal(response: Response, data: unknown): OneRefusal | null {
|
|
82
87
|
if (response.ok) return null;
|
|
83
88
|
const fromOne =
|
|
84
|
-
typeof data === "object" &&
|
|
89
|
+
typeof data === "object" &&
|
|
90
|
+
data !== null &&
|
|
91
|
+
"correlationId" in (data as Record<string, unknown>);
|
|
85
92
|
if (!fromOne) return null;
|
|
86
93
|
if (response.status === 403) return "grant";
|
|
87
94
|
if (response.status === 402) return "plan_limit";
|
|
@@ -89,6 +96,39 @@ function oneRefusal(response: Response, data: unknown): OneRefusal | null {
|
|
|
89
96
|
return "one_error";
|
|
90
97
|
}
|
|
91
98
|
|
|
99
|
+
/**
|
|
100
|
+
* One's rate limit from a reply's headers, or `null` when it sent none of
|
|
101
|
+
* them. A missing or unreadable header reads `null` on its own and never
|
|
102
|
+
* throws. One writes "no limit" as the largest 64-bit integer, which
|
|
103
|
+
* reads as `null` too.
|
|
104
|
+
*/
|
|
105
|
+
function rateLimitFrom(headers: Headers): RateLimit | null {
|
|
106
|
+
const read = (name: string): number | null => {
|
|
107
|
+
const value = headers.get(name)?.trim();
|
|
108
|
+
if (!value) return null;
|
|
109
|
+
const number = Number(value);
|
|
110
|
+
return Number.isFinite(number) && number >= 0 ? number : null;
|
|
111
|
+
};
|
|
112
|
+
const limit = read("x-ratelimit-limit");
|
|
113
|
+
const remaining = read("x-ratelimit-remaining");
|
|
114
|
+
const resetsIn = read("x-ratelimit-reset");
|
|
115
|
+
const retryAfter = read("retry-after");
|
|
116
|
+
if (
|
|
117
|
+
limit === null &&
|
|
118
|
+
remaining === null &&
|
|
119
|
+
resetsIn === null &&
|
|
120
|
+
retryAfter === null
|
|
121
|
+
)
|
|
122
|
+
return null;
|
|
123
|
+
const unlimited = limit !== null && limit > Number.MAX_SAFE_INTEGER;
|
|
124
|
+
return {
|
|
125
|
+
limit: unlimited ? null : limit,
|
|
126
|
+
remaining: unlimited ? null : remaining,
|
|
127
|
+
resetsIn,
|
|
128
|
+
retryAfter,
|
|
129
|
+
};
|
|
130
|
+
}
|
|
131
|
+
|
|
92
132
|
const CATALOG_PAGE_SIZE = 100;
|
|
93
133
|
/** One's largest page; reading every connection takes the fewest calls. */
|
|
94
134
|
const CONNECTIONS_PAGE_SIZE = 150;
|
|
@@ -128,7 +168,9 @@ export function formEncode(value: unknown): string {
|
|
|
128
168
|
const walk = (prefix: string, v: unknown) => {
|
|
129
169
|
if (v === undefined || v === null) return;
|
|
130
170
|
if (Array.isArray(v))
|
|
131
|
-
v.forEach((item, i) =>
|
|
171
|
+
v.forEach((item, i) =>
|
|
172
|
+
walk(`${prefix}[${typeof item === "object" ? i : ""}]`, item),
|
|
173
|
+
);
|
|
132
174
|
else if (typeof v === "object")
|
|
133
175
|
for (const [k, inner] of Object.entries(v as Record<string, unknown>))
|
|
134
176
|
walk(prefix ? `${prefix}[${k}]` : k, inner);
|
|
@@ -188,10 +230,16 @@ export interface OneConnectClient {
|
|
|
188
230
|
) => Promise<PlatformAction[]>;
|
|
189
231
|
/** An action's guide, input shape, method and path. Read it before
|
|
190
232
|
* running an action for the first time. */
|
|
191
|
-
getActionKnowledge: (
|
|
233
|
+
getActionKnowledge: (
|
|
234
|
+
userId: string,
|
|
235
|
+
actionId: string,
|
|
236
|
+
) => Promise<ActionKnowledge>;
|
|
192
237
|
/** Runs one action through One with the grant: fills the path, encodes
|
|
193
238
|
* the body, adds what the action needs. */
|
|
194
|
-
runAction: (
|
|
239
|
+
runAction: (
|
|
240
|
+
userId: string,
|
|
241
|
+
input: RunActionInput,
|
|
242
|
+
) => Promise<RunActionResult>;
|
|
195
243
|
/** Any authenticated request to One's /v1 API, headers handled. */
|
|
196
244
|
fetch: (
|
|
197
245
|
userId: string,
|
|
@@ -235,9 +283,11 @@ export interface OneConnect extends OneConnectClient {
|
|
|
235
283
|
* so an app written before key mode existed keeps working untouched.
|
|
236
284
|
*/
|
|
237
285
|
function resolveMode(config: OneConnectServerConfig): OneConnectMode {
|
|
238
|
-
const given = config as Partial<OneConnectKeyConfig> &
|
|
286
|
+
const given = config as Partial<OneConnectKeyConfig> &
|
|
287
|
+
Partial<OneConnectTokenConfig>;
|
|
239
288
|
const mode: OneConnectMode | undefined =
|
|
240
|
-
given.mode ??
|
|
289
|
+
given.mode ??
|
|
290
|
+
(given.connectKey ? "key" : given.tokenStore ? "token" : undefined);
|
|
241
291
|
if (mode === undefined) {
|
|
242
292
|
throw new TypeError(
|
|
243
293
|
"createOneConnect needs a credential: pass `connectKey` and `userStore` (key mode, recommended), or `tokenStore` (token mode).",
|
|
@@ -258,7 +308,9 @@ function resolveMode(config: OneConnectServerConfig): OneConnectMode {
|
|
|
258
308
|
}
|
|
259
309
|
|
|
260
310
|
/** Key mode: a connect key for the app and one permanent id per user. */
|
|
261
|
-
export function createOneConnect(
|
|
311
|
+
export function createOneConnect(
|
|
312
|
+
config: OneConnectKeyConfig,
|
|
313
|
+
): OneConnectKeyClient;
|
|
262
314
|
/** Token mode: an access and a refresh token per user, kept fresh. */
|
|
263
315
|
export function createOneConnect(config: OneConnectTokenConfig): OneConnect;
|
|
264
316
|
export function createOneConnect(
|
|
@@ -268,7 +320,10 @@ export function createOneConnect(
|
|
|
268
320
|
config: OneConnectServerConfig,
|
|
269
321
|
): OneConnectKeyClient | OneConnect {
|
|
270
322
|
const mode = resolveMode(config);
|
|
271
|
-
const oneApiUrl = (config.oneApiUrl ?? DEFAULT_ONE_API_URL).replace(
|
|
323
|
+
const oneApiUrl = (config.oneApiUrl ?? DEFAULT_ONE_API_URL).replace(
|
|
324
|
+
/\/+$/,
|
|
325
|
+
"",
|
|
326
|
+
);
|
|
272
327
|
const authorizeUrl = `${oneApiUrl}/oauth/authorize`;
|
|
273
328
|
const tokenUrl = `${oneApiUrl}/oauth/token`;
|
|
274
329
|
const apiUrl = `${oneApiUrl}/v1`;
|
|
@@ -330,7 +385,10 @@ export function createOneConnect(
|
|
|
330
385
|
: null;
|
|
331
386
|
const tokenCredential =
|
|
332
387
|
mode === "token"
|
|
333
|
-
? createTokenCredential(
|
|
388
|
+
? createTokenCredential(
|
|
389
|
+
(config as OneConnectTokenConfig).tokenStore,
|
|
390
|
+
postToken,
|
|
391
|
+
)
|
|
334
392
|
: null;
|
|
335
393
|
const credential = (keyCredential ?? tokenCredential) as Credential;
|
|
336
394
|
|
|
@@ -352,7 +410,12 @@ export function createOneConnect(
|
|
|
352
410
|
if (input.loginHint) url.searchParams.set("login_hint", input.loginHint);
|
|
353
411
|
return {
|
|
354
412
|
redirectUrl: url.toString(),
|
|
355
|
-
cookie: txCookie(
|
|
413
|
+
cookie: txCookie(
|
|
414
|
+
state,
|
|
415
|
+
verifier,
|
|
416
|
+
config.redirectUri,
|
|
417
|
+
appPath(input.returnTo),
|
|
418
|
+
),
|
|
356
419
|
};
|
|
357
420
|
};
|
|
358
421
|
|
|
@@ -387,7 +450,10 @@ export function createOneConnect(
|
|
|
387
450
|
// The returned state names its own cookie. No cookie means a stale,
|
|
388
451
|
// foreign or forged state; the code is never exchanged in that case.
|
|
389
452
|
if (!code || !state || !verifier)
|
|
390
|
-
return fail(
|
|
453
|
+
return fail(
|
|
454
|
+
"expired",
|
|
455
|
+
"The attempt expired, or its state cookie was missing.",
|
|
456
|
+
);
|
|
391
457
|
|
|
392
458
|
try {
|
|
393
459
|
const response = await exchange(
|
|
@@ -401,7 +467,8 @@ export function createOneConnect(
|
|
|
401
467
|
// Tokens in token mode, the user's permanent id in key mode.
|
|
402
468
|
await credential.connected(input.userId, response);
|
|
403
469
|
} catch (error) {
|
|
404
|
-
const status =
|
|
470
|
+
const status =
|
|
471
|
+
error instanceof OneConnectError ? error.status : undefined;
|
|
405
472
|
return fail(
|
|
406
473
|
"failed",
|
|
407
474
|
status
|
|
@@ -425,7 +492,9 @@ export function createOneConnect(
|
|
|
425
492
|
init: RequestInit = {},
|
|
426
493
|
): Promise<Response> => {
|
|
427
494
|
const headers = new Headers(init.headers);
|
|
428
|
-
for (const [name, value] of Object.entries(
|
|
495
|
+
for (const [name, value] of Object.entries(
|
|
496
|
+
await credential.headers(userId),
|
|
497
|
+
))
|
|
429
498
|
headers.set(name, value);
|
|
430
499
|
return fetch(`${apiUrl}${path.startsWith("/") ? path : `/${path}`}`, {
|
|
431
500
|
...init,
|
|
@@ -438,7 +507,10 @@ export function createOneConnect(
|
|
|
438
507
|
* that needs nothing but the credential. Throws when the question
|
|
439
508
|
* itself cannot be answered, rather than guessing.
|
|
440
509
|
*/
|
|
441
|
-
const consentStands = async (
|
|
510
|
+
const consentStands = async (
|
|
511
|
+
userId: string,
|
|
512
|
+
refused: OneConnectError,
|
|
513
|
+
): Promise<boolean> => {
|
|
442
514
|
const probe = await oneFetch(userId, "/connections/reachable?limit=1");
|
|
443
515
|
if (probe.ok) return true;
|
|
444
516
|
const verdict = credential.refusal(probe.status, await probe.text());
|
|
@@ -465,7 +537,10 @@ export function createOneConnect(
|
|
|
465
537
|
`/connections/reachable?limit=${limit}&page=${page}`,
|
|
466
538
|
);
|
|
467
539
|
if (!response.ok) {
|
|
468
|
-
const refused = credential.refusal(
|
|
540
|
+
const refused = credential.refusal(
|
|
541
|
+
response.status,
|
|
542
|
+
await response.text(),
|
|
543
|
+
);
|
|
469
544
|
if (refused) throw refused;
|
|
470
545
|
throw new OneConnectError(
|
|
471
546
|
"request_failed",
|
|
@@ -494,7 +569,10 @@ export function createOneConnect(
|
|
|
494
569
|
return page.rows ?? [];
|
|
495
570
|
}
|
|
496
571
|
const first = await connectionsPage(userId, CONNECTIONS_PAGE_SIZE, 1);
|
|
497
|
-
const pages = Math.min(
|
|
572
|
+
const pages = Math.min(
|
|
573
|
+
Math.max(first.pages ?? 1, 1),
|
|
574
|
+
CONNECTIONS_MAX_PAGES,
|
|
575
|
+
);
|
|
498
576
|
const rest = await Promise.all(
|
|
499
577
|
Array.from({ length: pages - 1 }, (_, index) =>
|
|
500
578
|
connectionsPage(userId, CONNECTIONS_PAGE_SIZE, index + 2),
|
|
@@ -558,7 +636,9 @@ export function createOneConnect(
|
|
|
558
636
|
oneFetch(userId, pageUrl(index + 2))
|
|
559
637
|
.then((response) =>
|
|
560
638
|
response.ok
|
|
561
|
-
? (response.json() as Promise<{
|
|
639
|
+
? (response.json() as Promise<{
|
|
640
|
+
rows?: Record<string, unknown>[];
|
|
641
|
+
}>)
|
|
562
642
|
: null,
|
|
563
643
|
)
|
|
564
644
|
.catch(() => null),
|
|
@@ -578,32 +658,46 @@ export function createOneConnect(
|
|
|
578
658
|
const params = new URLSearchParams({
|
|
579
659
|
query,
|
|
580
660
|
limit: String(options.limit ?? SEARCH_DEFAULT_LIMIT),
|
|
581
|
-
[options.mode === "knowledge" ? "knowledgeAgent" : "executeAgent"]:
|
|
661
|
+
[options.mode === "knowledge" ? "knowledgeAgent" : "executeAgent"]:
|
|
662
|
+
"true",
|
|
582
663
|
});
|
|
583
664
|
const response = await oneFetch(
|
|
584
665
|
userId,
|
|
585
666
|
`/available-actions/search/${encodeURIComponent(platform)}?${params}`,
|
|
586
667
|
);
|
|
587
|
-
if (!response.ok)
|
|
668
|
+
if (!response.ok)
|
|
669
|
+
throw await catalogRefusal(userId, "action search", response);
|
|
588
670
|
const body = (await response.json()) as
|
|
589
|
-
| Record<string, unknown>[]
|
|
590
|
-
| { rows?: Record<string, unknown>[] };
|
|
671
|
+
Record<string, unknown>[] | { rows?: Record<string, unknown>[] };
|
|
591
672
|
return slim(Array.isArray(body) ? body : (body.rows ?? []));
|
|
592
673
|
};
|
|
593
674
|
|
|
594
675
|
/** One action's knowledge, cached for the life of the client: an
|
|
595
676
|
* action's guide does not change between two calls. */
|
|
596
677
|
const knowledgeCache = new Map<string, Promise<ActionKnowledge>>();
|
|
597
|
-
const getActionKnowledge = (
|
|
678
|
+
const getActionKnowledge = (
|
|
679
|
+
userId: string,
|
|
680
|
+
actionId: string,
|
|
681
|
+
): Promise<ActionKnowledge> => {
|
|
598
682
|
const cached = knowledgeCache.get(actionId);
|
|
599
683
|
if (cached) return cached;
|
|
600
684
|
const loading = (async () => {
|
|
601
|
-
const response = await oneFetch(
|
|
602
|
-
|
|
603
|
-
|
|
685
|
+
const response = await oneFetch(
|
|
686
|
+
userId,
|
|
687
|
+
`/knowledge?_id=${encodeURIComponent(actionId)}`,
|
|
688
|
+
);
|
|
689
|
+
if (!response.ok)
|
|
690
|
+
throw await catalogRefusal(userId, "action knowledge", response);
|
|
691
|
+
const body = (await response.json()) as {
|
|
692
|
+
rows?: Record<string, unknown>[];
|
|
693
|
+
};
|
|
604
694
|
const row = body.rows?.[0];
|
|
605
695
|
if (!row)
|
|
606
|
-
throw new OneConnectError(
|
|
696
|
+
throw new OneConnectError(
|
|
697
|
+
"request_failed",
|
|
698
|
+
`One has no action with the id ${actionId}.`,
|
|
699
|
+
404,
|
|
700
|
+
);
|
|
607
701
|
return toKnowledge(row);
|
|
608
702
|
})();
|
|
609
703
|
knowledgeCache.set(actionId, loading);
|
|
@@ -631,7 +725,8 @@ export function createOneConnect(
|
|
|
631
725
|
const path = fillPath(action.path, input.pathParams);
|
|
632
726
|
const search = new URLSearchParams();
|
|
633
727
|
for (const [key, value] of Object.entries(input.query ?? {}))
|
|
634
|
-
for (const item of Array.isArray(value) ? value : [value])
|
|
728
|
+
for (const item of Array.isArray(value) ? value : [value])
|
|
729
|
+
search.append(key, item);
|
|
635
730
|
const query = search.size ? `?${search}` : "";
|
|
636
731
|
|
|
637
732
|
const headers: Record<string, string> = {
|
|
@@ -656,7 +751,9 @@ export function createOneConnect(
|
|
|
656
751
|
body = formEncode(payload);
|
|
657
752
|
} else if (encoding === "multipart") {
|
|
658
753
|
const form = new FormData();
|
|
659
|
-
for (const [key, value] of Object.entries(
|
|
754
|
+
for (const [key, value] of Object.entries(
|
|
755
|
+
isPlainObject(payload) ? payload : {},
|
|
756
|
+
))
|
|
660
757
|
form.append(
|
|
661
758
|
key,
|
|
662
759
|
value instanceof Blob
|
|
@@ -678,6 +775,7 @@ export function createOneConnect(
|
|
|
678
775
|
body,
|
|
679
776
|
});
|
|
680
777
|
const text = await response.text();
|
|
778
|
+
const rateLimit = rateLimitFrom(response.headers);
|
|
681
779
|
if (!response.ok) {
|
|
682
780
|
const refused = credential.refusal(response.status, text);
|
|
683
781
|
if (refused?.code === "reconnect_required") {
|
|
@@ -686,7 +784,14 @@ export function createOneConnect(
|
|
|
686
784
|
// tells them apart: if that still answers, the consent stands
|
|
687
785
|
// and it was this call One refused.
|
|
688
786
|
if (await consentStands(userId, refused))
|
|
689
|
-
return {
|
|
787
|
+
return {
|
|
788
|
+
status: response.status,
|
|
789
|
+
ok: false,
|
|
790
|
+
blockedByGrant: true,
|
|
791
|
+
refusal: "grant",
|
|
792
|
+
rateLimit,
|
|
793
|
+
data: text,
|
|
794
|
+
};
|
|
690
795
|
throw refused;
|
|
691
796
|
}
|
|
692
797
|
// One refusing the credential is not an answer to the action.
|
|
@@ -699,7 +804,14 @@ export function createOneConnect(
|
|
|
699
804
|
/* the provider answered with something other than JSON */
|
|
700
805
|
}
|
|
701
806
|
const refusal = oneRefusal(response, data);
|
|
702
|
-
return {
|
|
807
|
+
return {
|
|
808
|
+
status: response.status,
|
|
809
|
+
ok: response.ok,
|
|
810
|
+
blockedByGrant: refusal === "grant",
|
|
811
|
+
refusal,
|
|
812
|
+
rateLimit,
|
|
813
|
+
data,
|
|
814
|
+
};
|
|
703
815
|
};
|
|
704
816
|
|
|
705
817
|
const shared = {
|
package/src/server/types.ts
CHANGED
|
@@ -144,7 +144,8 @@ export interface OneConnectTokenConfig extends OneConnectBaseConfig {
|
|
|
144
144
|
* mode, a `tokenStore` alone is token mode. Set `mode` to say so
|
|
145
145
|
* explicitly.
|
|
146
146
|
*/
|
|
147
|
-
export type OneConnectServerConfig =
|
|
147
|
+
export type OneConnectServerConfig =
|
|
148
|
+
OneConnectKeyConfig | OneConnectTokenConfig;
|
|
148
149
|
|
|
149
150
|
/** The transaction cookie the authorize leg sets and the callback reads. */
|
|
150
151
|
export interface OneConnectCookie {
|
|
@@ -302,6 +303,22 @@ export interface RunActionInput {
|
|
|
302
303
|
*/
|
|
303
304
|
export type OneRefusal = "grant" | "plan_limit" | "rate_limit" | "one_error";
|
|
304
305
|
|
|
306
|
+
/**
|
|
307
|
+
* One's rate limit for the user a call was made for, as One reported it on
|
|
308
|
+
* that call. The app owner's plan sets the size; each of the app's users
|
|
309
|
+
* has a bucket of their own. Any value One didn't send is `null`.
|
|
310
|
+
*/
|
|
311
|
+
export interface RateLimit {
|
|
312
|
+
/** Calls this user may make a minute. `null` when nothing limits them. */
|
|
313
|
+
limit: number | null;
|
|
314
|
+
/** Calls left in the current minute. `null` when nothing limits them. */
|
|
315
|
+
remaining: number | null;
|
|
316
|
+
/** Seconds until the minute resets. */
|
|
317
|
+
resetsIn: number | null;
|
|
318
|
+
/** Seconds to wait before trying again. Set on a 429 only. */
|
|
319
|
+
retryAfter: number | null;
|
|
320
|
+
}
|
|
321
|
+
|
|
305
322
|
export interface RunActionResult {
|
|
306
323
|
status: number;
|
|
307
324
|
ok: boolean;
|
|
@@ -314,6 +331,11 @@ export interface RunActionResult {
|
|
|
314
331
|
/** Why One turned the call down, or `null` when it didn't (the call
|
|
315
332
|
* succeeded, or the provider answered with its own error). */
|
|
316
333
|
refusal: OneRefusal | null;
|
|
334
|
+
/** One's rate limit for this user after the call, or `null` when One
|
|
335
|
+
* sent none of its rate-limit headers. A `refusal` of `"plan_limit"`
|
|
336
|
+
* (402) means this user's calls for the month are used up: back off
|
|
337
|
+
* for the month, don't retry. */
|
|
338
|
+
rateLimit: RateLimit | null;
|
|
317
339
|
data: unknown;
|
|
318
340
|
}
|
|
319
341
|
|
|
@@ -329,10 +351,7 @@ export interface RunActionResult {
|
|
|
329
351
|
* reached. Nothing stored was changed, so retry later.
|
|
330
352
|
*/
|
|
331
353
|
export type OneConnectErrorCode =
|
|
332
|
-
| "
|
|
333
|
-
| "reconnect_required"
|
|
334
|
-
| "refresh_failed"
|
|
335
|
-
| "request_failed";
|
|
354
|
+
"not_connected" | "reconnect_required" | "refresh_failed" | "request_failed";
|
|
336
355
|
|
|
337
356
|
export class OneConnectError extends Error {
|
|
338
357
|
readonly code: OneConnectErrorCode;
|