@notionhq/custom-blocks-host 0.5.1 → 0.6.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 +9 -0
- package/dist/browser.js +1 -1
- package/dist/compatibility/normalizeHostToSandboxMessage.d.ts.map +1 -1
- package/dist/compatibility/normalizeHostToSandboxMessage.js +5 -1
- package/dist/compatibility/normalizeSandboxToHostMessage.d.ts +88 -1
- package/dist/compatibility/normalizeSandboxToHostMessage.d.ts.map +1 -1
- package/dist/compatibility/pages/toIconForProtocol3To8.d.ts +4 -0
- package/dist/compatibility/pages/toIconForProtocol3To8.d.ts.map +1 -0
- package/dist/compatibility/pages/toIconForProtocol3To8.js +13 -0
- package/dist/compatibility/protocol3To5/toPageForProtocol3To5.d.ts.map +1 -1
- package/dist/compatibility/protocol3To5/toPageForProtocol3To5.js +2 -1
- package/dist/compatibility/protocol3To5/toQueryPageForProtocol3To5.d.ts +8 -8
- package/dist/compatibility/protocol6/normalizePageResultsForProtocol6.d.ts.map +1 -1
- package/dist/compatibility/protocol6/normalizePageResultsForProtocol6.js +9 -2
- package/dist/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.d.ts +4 -0
- package/dist/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.d.ts.map +1 -0
- package/dist/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.js +16 -0
- package/dist/createCustomBlockHost.d.ts.map +1 -1
- package/dist/createCustomBlockHost.js +50 -34
- package/dist/index.d.ts +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/messages/createSandboxMessageRouter.d.ts +3 -2
- package/dist/messages/createSandboxMessageRouter.d.ts.map +1 -1
- package/dist/messages/createSandboxMessageRouter.js +7 -1
- package/dist/messages/getInvalidSandboxMessageResponse.d.ts.map +1 -1
- package/dist/messages/getInvalidSandboxMessageResponse.js +3 -0
- package/dist/messages/invalidNativeIconColor.d.ts +5 -0
- package/dist/messages/invalidNativeIconColor.d.ts.map +1 -0
- package/dist/messages/invalidNativeIconColor.js +34 -0
- package/dist/pages/types.d.ts +2 -0
- package/dist/pages/types.d.ts.map +1 -1
- package/dist/protocol/compatibility/protocol3To5/bridgePage.d.ts +7 -1
- package/dist/protocol/dataSources/messages/queryDataSource.d.ts +14 -2
- package/dist/protocol/icons.d.ts +17 -0
- package/dist/protocol/icons.js +27 -0
- package/dist/protocol/index.d.ts +5 -3
- package/dist/protocol/index.js +4 -2
- package/dist/protocol/messages/hostToSandbox.d.ts +79 -11
- package/dist/protocol/messages/invalidHostMessage.d.ts +2 -0
- package/dist/protocol/messages/invalidHostMessage.js +2 -0
- package/dist/protocol/messages/invalidSandboxMessage.d.ts +2 -0
- package/dist/protocol/messages/invalidSandboxMessage.js +2 -0
- package/dist/protocol/messages/sandboxToHost.d.ts +88 -1
- package/dist/protocol/navigation/openExternalUrl.d.ts +2 -2
- package/dist/protocol/pages/bridgePage.d.ts +7 -1
- package/dist/protocol/pages/messages/createPage.d.ts +103 -5
- package/dist/protocol/pages/messages/createPage.js +3 -1
- package/dist/protocol/pages/messages/getPage.d.ts +23 -5
- package/dist/protocol/pages/messages/openPage.d.ts +2 -2
- package/dist/protocol/pages/messages/updatePage.d.ts +30 -6
- package/dist/protocol/pages/pageAppearance.d.ts +36 -1
- package/dist/protocol/pages/pageAppearance.js +9 -0
- package/dist/protocol/users/messages/getUser.d.ts +2 -2
- package/dist/protocol/users/messages/listUsers.d.ts +2 -2
- package/dist/protocol/utils/errors.d.ts +2 -0
- package/dist/protocol/utils/protocolVersion.d.ts +2 -1
- package/dist/protocol/utils/protocolVersion.js +3 -1
- package/dist/protocol/utils/readRequestId.d.ts +2 -0
- package/dist/protocol/utils/readRequestId.js +7 -0
- package/docs/bridge/changelog.md +19 -0
- package/docs/bridge/protocol.md +30 -1
- package/docs/bridge/versioning.md +1 -0
- package/docs/compatibility.md +15 -7
- package/docs/handlers.md +6 -3
- package/package.json +1 -1
- package/src/compatibility/normalizeHostToSandboxMessage.ts +5 -0
- package/src/compatibility/pages/toIconForProtocol3To8.ts +17 -0
- package/src/compatibility/protocol3To5/toPageForProtocol3To5.ts +2 -1
- package/src/compatibility/protocol6/normalizePageResultsForProtocol6.ts +11 -2
- package/src/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.ts +22 -0
- package/src/createCustomBlockHost.ts +57 -37
- package/src/index.ts +1 -0
- package/src/messages/createSandboxMessageRouter.ts +18 -2
- package/src/messages/getInvalidSandboxMessageResponse.ts +3 -0
- package/src/messages/invalidNativeIconColor.ts +43 -0
- package/src/pages/types.ts +3 -0
package/README.md
CHANGED
|
@@ -182,3 +182,12 @@ These schemas validate wire payloads. Your application still enforces permission
|
|
|
182
182
|
|
|
183
183
|
`dist/browser.js` is one ES module with all dependencies. Use it when the browser must not fetch
|
|
184
184
|
additional modules, such as under an exact-URL Content Security Policy.
|
|
185
|
+
|
|
186
|
+
### Native page icons
|
|
187
|
+
|
|
188
|
+
`CustomBlockHostPageIcon` accepts canonical native icon names from adapters. Adapters validate names
|
|
189
|
+
and colors before writing. The runtime validates response payloads.
|
|
190
|
+
|
|
191
|
+
Adapters must check URL-backed icon and cover writes against the block's network permissions before
|
|
192
|
+
mutating records. Notion permits the submitted HTTPS destination only when its origin is
|
|
193
|
+
allowlisted; that origin is trusted to redirect.
|
package/dist/browser.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
var Le,Jo={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function st(e){return!e&&!Le?Jo:{lang:e?.lang??Le?.lang,message:e?.message,abortEarly:e?.abortEarly??Le?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Le?.abortPipeEarly}}var Yo;function en(e){return Yo?.get(e)}var tn;function rn(e){return tn?.get(e)}var on;function nn(e,t){return on?.get(e)?.get(t)}function ke(e){let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function w(e,t,i,s,c){let p=c&&"input"in c?c.input:i.value,f=c?.expected??e.expects??null,h=c?.received??ke(p),y={kind:e.kind,type:e.type,input:p,expected:f,received:h,message:`Invalid ${t}: ${f?`Expected ${f} but r`:"R"}eceived ${h}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},C=e.kind==="schema",_=c?.message??e.message??nn(e.reference,y.lang)??(C?rn(y.lang):null)??s.message??en(y.lang);_!==void 0&&(y.message=typeof _=="function"?_(y):_),C&&(i.typed=!1),i.issues?i.issues.push(y):i.issues=[y]}function sn(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function an(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function at(e,t){let i=[...new Set(e)];return i.length>1?`(${i.join(` ${t} `)})`:i[0]??"never"}function W(e){return e["~standard"]={version:1,vendor:"valibot",validate:t=>e["~run"]({value:t},st())},e}var un=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function ce(e){return{kind:"transformation",type:"brand",reference:ce,async:!1,name:e,"~run"(t){return t}}}function De(e){return{kind:"validation",type:"finite",reference:De,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(t,i){return t.typed&&!this.requirement(t.value)&&w(this,"finite",t,i),t}}}function ut(e,t){let i=ke(e);return{kind:"validation",type:"includes",reference:ut,async:!1,expects:i,requirement:e,message:t,"~run"(s,c){return s.typed&&!s.value.includes(this.requirement)&&w(this,"content",s,c,{received:`!${i}`}),s}}}function we(e,t){return{kind:"validation",type:"max_length",reference:we,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(i,s){return i.typed&&i.value.length>this.requirement&&w(this,"length",i,s,{received:`${i.value.length}`}),i}}}function he(e,t){return{kind:"validation",type:"min_length",reference:he,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(i,s){return i.typed&&i.value.length<this.requirement&&w(this,"length",i,s,{received:`${i.value.length}`}),i}}}function Te(e,t){return{kind:"validation",type:"min_value",reference:Te,async:!1,expects:`>=${e instanceof Date?e.toJSON():ke(e)}`,requirement:e,message:t,"~run"(i,s){return i.typed&&!(i.value>=this.requirement)&&w(this,"value",i,s,{received:i.value instanceof Date?i.value.toJSON():ke(i.value)}),i}}}function ct(e,t){return{kind:"validation",type:"regex",reference:ct,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(i,s){return i.typed&&!this.requirement.test(i.value)&&w(this,"format",i,s),i}}}function lt(e){return{kind:"transformation",type:"transform",reference:lt,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}var Dt={abortEarly:!0};function wt(e,t,i){return typeof e.fallback=="function"?e.fallback(t,i):e.fallback}function Ve(e,t,i){return typeof e.default=="function"?e.default(t,i):e.default}function Tt(e,t){return!e["~run"]({value:t},Dt).issues}function E(e,t){return W({kind:"schema",type:"array",reference:E,expects:"Array",async:!1,item:e,message:t,"~run"(i,s){let c=i.value;if(Array.isArray(c)){i.typed=!0,i.value=[];for(let p=0;p<c.length;p++){let f=c[p],h=this.item["~run"]({value:f},s);if(h.issues){let y={type:"array",origin:"value",input:c,key:p,value:f};for(let C of h.issues)C.path?C.path.unshift(y):C.path=[y],i.issues?.push(C);if(i.issues||(i.issues=h.issues),s.abortEarly){i.typed=!1;break}}h.typed||(i.typed=!1),i.value.push(h.value)}}else w(this,"type",i,s);return i}})}function b(e){return W({kind:"schema",type:"boolean",reference:b,expects:"boolean",async:!1,message:e,"~run"(t,i){return typeof t.value=="boolean"?t.typed=!0:w(this,"type",t,i),t}})}function n(e,t){return W({kind:"schema",type:"literal",reference:n,expects:ke(e),async:!1,literal:e,message:t,"~run"(i,s){return sn(i.value,this.literal)?i.typed=!0:w(this,"type",i,s),i}})}function pt(e){return W({kind:"schema",type:"nan",reference:pt,expects:"NaN",async:!1,message:e,"~run"(t,i){return Number.isNaN(t.value)?t.typed=!0:w(this,"type",t,i),t}})}function mt(e){return W({kind:"schema",type:"never",reference:mt,expects:"never",async:!1,message:e,"~run"(t,i){return w(this,"type",t,i),t}})}function D(e,t){return W({kind:"schema",type:"nullable",reference:D,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,"~run"(i,s){return i.value===null&&(this.default!==void 0&&(i.value=Ve(this,i,s)),i.value===null)?(i.typed=!0,i):this.wrapped["~run"](i,s)}})}function O(e){return W({kind:"schema",type:"number",reference:O,expects:"number",async:!1,message:e,"~run"(t,i){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:w(this,"type",t,i),t}})}function o(e,t){return W({kind:"schema",type:"object",reference:o,expects:"Object",async:!1,entries:e,message:t,"~run"(i,s){let c=i.value;if(c&&typeof c=="object"){i.typed=!0,i.value={};for(let p in this.entries){let f=this.entries[p];if(p in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let h=p in c?c[p]:Ve(f),y=f["~run"]({value:h},s);if(y.issues){let C={type:"object",origin:"value",input:c,key:p,value:h};for(let _ of y.issues)_.path?_.path.unshift(C):_.path=[C],i.issues?.push(_);if(i.issues||(i.issues=y.issues),s.abortEarly){i.typed=!1;break}}y.typed||(i.typed=!1),i.value[p]=y.value}else if(f.fallback!==void 0)i.value[p]=wt(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(w(this,"key",i,s,{input:void 0,expected:`"${p}"`,path:[{type:"object",origin:"key",input:c,key:p,value:c[p]}]}),s.abortEarly))break}}else w(this,"type",i,s);return i}})}function a(e,t){return W({kind:"schema",type:"optional",reference:a,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,"~run"(i,s){return i.value===void 0&&(this.default!==void 0&&(i.value=Ve(this,i,s)),i.value===void 0)?(i.typed=!0,i):this.wrapped["~run"](i,s)}})}function T(e,t){return W({kind:"schema",type:"picklist",reference:T,expects:at(e.map(ke),"|"),async:!1,options:e,message:t,"~run"(i,s){return this.options.includes(i.value)?i.typed=!0:w(this,"type",i,s),i}})}function $(e,t,i){return W({kind:"schema",type:"record",reference:$,expects:"Object",async:!1,key:e,value:t,message:i,"~run"(s,c){let p=s.value;if(p&&typeof p=="object"){s.typed=!0,s.value={};for(let f in p)if(an(p,f)){let h=p[f],y=this.key["~run"]({value:f},c);if(y.issues){let _={type:"object",origin:"key",input:p,key:f,value:h};for(let M of y.issues)M.path=[_],s.issues?.push(M);if(s.issues||(s.issues=y.issues),c.abortEarly){s.typed=!1;break}}let C=this.value["~run"]({value:h},c);if(C.issues){let _={type:"object",origin:"value",input:p,key:f,value:h};for(let M of C.issues)M.path?M.path.unshift(_):M.path=[_],s.issues?.push(M);if(s.issues||(s.issues=C.issues),c.abortEarly){s.typed=!1;break}}(!y.typed||!C.typed)&&(s.typed=!1),y.typed&&(s.value[y.value]=C.value)}}else w(this,"type",s,c);return s}})}function l(e,t){return W({kind:"schema",type:"strict_object",reference:l,expects:"Object",async:!1,entries:e,message:t,"~run"(i,s){let c=i.value;if(c&&typeof c=="object"){i.typed=!0,i.value={};for(let p in this.entries){let f=this.entries[p];if(p in c||(f.type==="exact_optional"||f.type==="optional"||f.type==="nullish")&&f.default!==void 0){let h=p in c?c[p]:Ve(f),y=f["~run"]({value:h},s);if(y.issues){let C={type:"object",origin:"value",input:c,key:p,value:h};for(let _ of y.issues)_.path?_.path.unshift(C):_.path=[C],i.issues?.push(_);if(i.issues||(i.issues=y.issues),s.abortEarly){i.typed=!1;break}}y.typed||(i.typed=!1),i.value[p]=y.value}else if(f.fallback!==void 0)i.value[p]=wt(f);else if(f.type!=="exact_optional"&&f.type!=="optional"&&f.type!=="nullish"&&(w(this,"key",i,s,{input:void 0,expected:`"${p}"`,path:[{type:"object",origin:"key",input:c,key:p,value:c[p]}]}),s.abortEarly))break}if(!i.issues||!s.abortEarly){for(let p in c)if(!Object.prototype.hasOwnProperty.call(this.entries,p)){w(this,"key",i,s,{input:p,expected:"never",path:[{type:"object",origin:"key",input:c,key:p,value:c[p]}]});break}}}else w(this,"type",i,s);return i}})}function r(e){return W({kind:"schema",type:"string",reference:r,expects:"string",async:!1,message:e,"~run"(t,i){return typeof t.value=="string"?t.typed=!0:w(this,"type",t,i),t}})}function Mt(e){let t;if(e)for(let i of e)if(t)for(let s of i.issues)t.push(s);else t=i.issues;return t}function d(e,t){return W({kind:"schema",type:"union",reference:d,expects:at(e.map(i=>i.expects),"|"),async:!1,options:e,message:t,"~run"(i,s){let c,p,f;for(let h of this.options){let y=h["~run"]({value:i.value},s);if(y.typed)if(y.issues)p?p.push(y):p=[y];else{c=y;break}else f?f.push(y):f=[y]}if(c)return c;if(p){if(p.length===1)return p[0];w(this,"type",i,s,{issues:Mt(p)}),i.typed=!0}else{if(f?.length===1)return f[0];w(this,"type",i,s,{issues:Mt(f)})}return i}})}function qe(){return W({kind:"schema",type:"unknown",reference:qe,expects:"unknown",async:!1,"~run"(e){return e.typed=!0,e}})}function v(e,t,i){return W({kind:"schema",type:"variant",reference:v,expects:"Object",async:!1,key:e,options:t,message:i,"~run"(s,c){let p=s.value;if(p&&typeof p=="object"){let f,h=0,y=this.key,C=[],_=(M,X)=>{for(let V of M.options){if(V.type==="variant")_(V,new Set(X).add(V.key));else{let g=!0,N=0;for(let B of X){let z=V.entries[B];if(B in p?z["~run"]({typed:!1,value:p[B]},Dt).issues:z.type!=="exact_optional"&&z.type!=="optional"&&z.type!=="nullish"){g=!1,y!==B&&(h<N||h===N&&B in p&&!(y in p))&&(h=N,y=B,C=[]),y===B&&C.push(V.entries[B].expects);break}N++}if(g){let B=V["~run"]({value:p},c);(!f||!f.typed&&B.typed)&&(f=B)}}if(f&&!f.issues)break}};if(_(this,new Set([this.key])),f)return f;w(this,"type",s,c,{input:p[y],expected:at(C,"|"),path:[{type:"object",origin:"value",input:p,key:y,value:p[y]}]})}else w(this,"type",s,c);return s}})}function qt(e,t){let i={...e.entries};for(let s of t)delete i[s];return W({...e,entries:i})}function se(e,t,i){let s=e["~run"]({value:t},st(i));if(s.issues)throw new un(s.issues);return s.value}function A(...e){return W({...e[0],pipe:e,"~run"(t,i){for(let s of e)if(s.kind!=="metadata"){if(t.issues&&(s.kind==="schema"||s.kind==="transformation")){t.typed=!1;break}(!t.issues||!i.abortEarly&&!i.abortPipeEarly)&&(t=s["~run"](t,i))}return t}})}function Ie(e,t,i){let s=e["~run"]({value:t},st(i));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}var le=A(r(),ce("NotionBlockId")),Z=A(r(),ce("NotionDataSourceId")),F=A(r(),ce("NotionPageId")),At=A(r(),ce("NotionAgentId")),Nt=A(r(),ce("NotionSpaceId"));var Ut=o({id:Z,table:r(),spaceId:a(Nt)});var Ft=T(["default","gray","brown","orange","yellow","green","blue","purple","pink","red","gray_background","brown_background","orange_background","yellow_background","green_background","blue_background","purple_background","pink_background","red_background","default_background"]),ft=o({id:r(),name:r(),color:a(Ft),description:a(r())}),cn=o({id:r(),name:r(),color:a(Ft),option_ids:E(r())}),ln=o({synced_property_id:r(),synced_property_name:r()}),j=o({name:r(),description:a(r())}),pn=["title","rich_text","number","checkbox","url","email","phone_number","select","multi_select","status","date","people","files","unique_id","relation","place","formula","rollup","button","verification","last_visited_time","location","created_time","last_edited_time","created_by","last_edited_by"],zt=T(pn),Ht=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],Lt=v("type",[o({...j.entries,type:n("title")}),o({...j.entries,type:n("rich_text")}),o({...j.entries,type:n("number")}),o({...j.entries,type:n("checkbox")}),o({...j.entries,type:n("url")}),o({...j.entries,type:n("email")}),o({...j.entries,type:n("phone_number")}),o({...j.entries,type:n("select"),options:E(ft)}),o({...j.entries,type:n("multi_select"),options:E(ft)}),o({...j.entries,type:n("status"),options:E(ft),groups:E(cn)}),o({...j.entries,type:n("date")}),o({...j.entries,type:n("people")}),o({...j.entries,type:n("files")}),o({...j.entries,type:n("unique_id")}),o({...j.entries,type:n("relation"),data_source_id:a(r()),dual_property:a(ln)}),o({...j.entries,type:n("place")}),o({...j.entries,type:n("formula")}),o({...j.entries,type:n("rollup")}),o({...j.entries,type:n("button")}),o({...j.entries,type:n("verification")}),o({...j.entries,type:n("last_visited_time")}),o({...j.entries,type:n("location")}),o({...j.entries,type:n("created_time")}),o({...j.entries,type:n("last_edited_time")}),o({...j.entries,type:n("created_by")}),o({...j.entries,type:n("last_edited_by")})]);var Vt={created_time:{type:"created_time",name:"Created time"},last_edited_time:{type:"last_edited_time",name:"Last edited time"},created_by:{type:"created_by",name:"Created by"},last_edited_by:{type:"last_edited_by",name:"Last edited by"}};var Gt=o({id:a(Z),propertiesById:$(r(),Lt)});var $t=o({collectionPointer:a(Ut),collectionSchema:a(Gt),propertyIdsByKey:a($(r(),a(r()))),inaccessible:a(n(!0))});var ye=$(r(),$t);function Qt(e){let t=Object.entries(e.manifestDataSource.properties??{}).map(([i,s])=>{let c=e.propertyIdsByKey?.[i],p=c===void 0?void 0:e.collectionSchema?.propertiesById[c];return mn(i,c,p?.type,s.type)});return e.collectionSchema===void 0?{status:"missing_schema",properties:t}:t.every(i=>i.status==="mapped")?{status:"complete",properties:t}:{status:"incomplete",properties:t}}function mn(e,t,i,s){return t===void 0?{status:"missing",propertyKey:e,propertyId:t}:i===void 0?{status:"invalid",propertyKey:e,propertyId:t}:{status:i===s?"mapped":"incompatible",propertyKey:e,propertyId:t}}var Ge=o({type:n("page_id"),page_id:F}),$e=o({type:n("data_source_id"),data_source_id:Z}),fn=o({type:n("workspace"),workspace:n(!0)}),yn=o({type:n("block_id"),block_id:le}),dn=o({type:n("agent_id"),agent_id:At}),vn=o({type:n("unavailable")}),re=v("type",[Ge,$e,fn,yn,dn,vn]);var _e=v("type",[o({type:n("unavailable")}),o({type:n("page"),id:F,parent:re})]);var xe=T(["standard","high"]),Wt="standard";var Ce=T(["light","dark"]);var Xt=o({capability:r(),resource:r()});var hn=v("type",[o({type:n("emoji"),emoji:r()}),o({type:n("external"),url:r()})]),gn=o({name:r(),description:a(r()),type:zt}),bn=o({name:r(),description:a(r()),icon:a(hn),properties:a($(r(),gn),{})}),de=o({version:n(1),name:a(r()),description:a(r()),slashCommand:a(r()),icon:a(o({type:n("emoji"),emoji:r()})),dataSources:a($(r(),bn),{}),capabilities:a(E(Xt))});var Qe=A(r(),ce("NotionUserId"));var ae=o({object:n("user"),id:Qe,name:a(r()),avatar_url:D(r()),type:n("person"),person:o({email:r()})});var Sn=r(),Ne=o({code:Sn,message:r(),isRetryable:b()}),Ae=class extends Error{constructor(t){super(t.message),this.name="CustomBlockInitializationError",this.code=t.code,this.isRetryable=t.isRetryable}code;isRetryable},We=v("status",[o({type:n("init"),initializationId:r(),status:n("success"),theme:Ce,contrastMode:xe,blockId:le,parent:re,page:_e,manifest:de,dataSources:o({bindings:ye}),currentUser:ae}),o({type:n("init"),initializationId:r(),status:n("error"),error:Ne})]);var Kt=o({type:n("contrastModeChanged"),contrastMode:xe});var Zt=o({type:n("pageChanged"),page:_e});var Jt=o({type:n("parentChanged"),parent:re});var Yt=o({type:n("themeChanged"),theme:Ce});var er=o({type:n("dataSourcesChanged"),dataSources:o({bindings:ye})});var Xe=o({unit:T(["year","month","week","day"]),value:O(),time:r(),defaultTimeZone:a(r())}),kn=o({unit:T(["hour","minute"]),value:O()}),Ue=o({unit:n("none")}),yt=d([Xe,kn]),tr=a(d([Xe,Ue])),rr=a(d([yt,Ue])),In=o({type:n("date"),start_date:r(),reminder:tr}),_n=o({type:n("daterange"),start_date:r(),end_date:r(),reminder:tr}),xn=o({type:n("datetime"),start_date:r(),start_time:r(),time_zone:a(r()),reminder:rr}),Cn=o({type:n("datetimerange"),start_date:r(),start_time:r(),end_date:r(),end_time:r(),time_zone:a(r()),reminder:rr}),or=v("type",[In,_n,xn,Cn]);var Ke=o({id:r(),table:r()});var nr=d([r(),O(),b(),or,E(r()),E(Ke)]);var ir=o({id:F,is_archived:b(),in_trash:b(),propertiesById:$(r(),a(nr))});var Pn=o({type:n("emoji"),emoji:r()}),En=o({type:n("custom_emoji"),custom_emoji:o({id:r(),name:a(r()),url:a(r())})}),sr=o({type:n("external"),external:o({url:r()})}),ar=o({type:n("file"),file:o({url:r(),expiry_time:a(r())})}),Pe=v("type",[Pn,En,sr,ar]),Ee=v("type",[sr,ar]);var L=D(r());var dt={start:r(),end:a(L),time_zone:a(L),reminder:a(d([yt,Ue]))},ur=d([o({...dt,start:A(r(),ut("T"))}),o({...dt,time_zone:r()}),o({...dt,reminder:a(d([Xe,Ue]))})]);var cr=d([o({type:n("external"),name:r(),external:o({url:r()})}),o({type:n("file"),name:r(),file:o({url:r(),expiry_time:a(r())})})]);var Oe=D(o({...Ke.entries,table:T(["notion_user","bot","organization_bot"]),spaceId:a(r())}));var lr=o({lat:O(),lon:O(),name:a(L),address:a(L),aws_place_id:a(L),google_place_id:a(L)});var pr=o({id:r()});var vt=$(r(),qe());var Ze=d([o({id:r(),name:a(r()),color:a(r()),description:a(L)}),o({name:r(),id:a(r()),color:a(r()),description:a(L)})]);var mr=d([o({object:a(n("user")),id:r()}),o({object:n("group"),id:r(),name:a(L)})]);var R={id:r()},ht=v("type",[o({...R,type:n("title"),title:E(vt)}),o({...R,type:n("rich_text"),rich_text:E(vt)}),o({...R,type:n("number"),number:D(O())}),o({...R,type:n("url"),url:L}),o({...R,type:n("email"),email:L}),o({...R,type:n("phone_number"),phone_number:L}),o({...R,type:n("checkbox"),checkbox:b()}),o({...R,type:n("select"),select:D(Ze)}),o({...R,type:n("status"),status:D(Ze)}),o({...R,type:n("multi_select"),multi_select:E(Ze)}),o({...R,type:n("date"),date:D(ur)}),o({...R,type:n("people"),people:E(mr)}),o({...R,type:n("relation"),has_more:a(b()),relation:E(pr)}),o({...R,type:n("files"),files:E(cr)}),o({...R,type:n("place"),place:D(lr)}),o({...R,type:n("created_time"),created_time:L}),o({...R,type:n("last_edited_time"),last_edited_time:L}),o({...R,type:n("created_by"),created_by:Oe}),o({...R,type:n("last_edited_by"),last_edited_by:Oe}),o({...R,type:n("last_visited_time"),last_visited_time:L}),o({...R,type:n("unique_id"),unique_id:r()}),o({...R,type:n("button"),button:r()}),o({...R,type:n("formula"),formula:r()}),o({...R,type:n("location"),location:r()}),o({...R,type:n("rollup"),rollup:r()}),o({...R,type:n("verification"),verification:r()})]);var Be=$(r(),ht),fr=$(r(),D(ht));var oe=o({object:n("page"),id:F,parent:re,properties:fr,created_by:a(Oe,null),last_edited_by:a(Oe,null),last_visited_time:a(D(r()),null),created_time:a(D(r()),null),last_edited_time:a(D(r()),null),icon:a(D(Pe),null),cover:a(D(Ee),null),url:a(D(r()),null),public_url:a(D(r()),null),is_archived:b(),in_trash:b()});var yr=d([l({equals:b()}),l({does_not_equal:b()})]);var ue=d([l({is_empty:n(!0)}),l({is_not_empty:n(!0)})]);var ge=d([r(),E(r())]);var dr=d([l({contains:ge}),l({contains_all:ge}),l({does_not_contain:ge}),ue]);var vr=l({object:n("user"),id:A(r(),he(1),we(2e3))}),hr=d([l({contains:vr}),l({does_not_contain:vr}),l({is_empty:n(!0)}),l({is_not_empty:n(!0)})]);var J=T(["start_date","end_date"]),On=T(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),Fe=d([On,r()]),gr=d([l({target:a(J),equals:Fe}),l({target:a(J),before:Fe}),l({target:a(J),after:Fe}),l({target:a(J),on_or_before:Fe}),l({target:a(J),on_or_after:Fe}),l({target:a(J),this_week:l({})}),l({target:a(J),past_week:l({})}),l({target:a(J),past_month:l({})}),l({target:a(J),past_year:l({})}),l({target:a(J),next_week:l({})}),l({target:a(J),next_month:l({})}),l({target:a(J),next_year:l({})}),l({target:a(J),is_empty:n(!0)}),l({target:a(J),is_not_empty:n(!0)})]);var br=d([l({equals:O()}),l({does_not_equal:O()}),l({greater_than:O()}),l({less_than:O()}),l({greater_than_or_equal_to:O()}),l({less_than_or_equal_to:O()}),ue]);var Je=d([l({equals:ge}),l({does_not_equal:ge}),ue]);var Sr=l({object:T(["user","group"]),id:A(r(),he(1))}),kr=d([l({contains:Sr}),l({does_not_contain:Sr}),ue]);var Ir=A(F,ct(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i),lt(e=>e.replaceAll("-","").toLowerCase().replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5"))),Ye=d([l({contains:Ir}),l({does_not_contain:Ir}),l({is_empty:n(!0)}),l({is_not_empty:n(!0)})]);var _r=T(["To-do","In progress","Complete","Current","Future"]),xr=d([_r,A(E(_r),he(1),we(5))]),Cr=d([l({group_equals:xr}),l({group_does_not_equal:xr})]);var Pr=d([Je,Cr]);var je=d([l({equals:r()}),l({does_not_equal:r()}),l({contains:r()}),l({does_not_contain:r()}),l({starts_with:r()}),l({ends_with:r()}),ue]);var gt=d([l({propertyId:r(),relation:Ye}),l({propertyId:r(),created_by:hr}),l({propertyId:r(),title:je}),l({propertyId:r(),rich_text:je}),l({propertyId:r(),url:je}),l({propertyId:r(),email:je}),l({propertyId:r(),phone_number:je}),l({propertyId:r(),number:br}),l({propertyId:r(),checkbox:yr}),l({propertyId:r(),select:Je}),l({propertyId:r(),multi_select:dr}),l({propertyId:r(),status:Pr}),l({propertyId:r(),date:gr}),l({propertyId:r(),people:kr})]);var Er=d([gt,l({and:E(gt)})]);var Or=T(["ascending","descending"]);var bt=10,Br=l({propertyId:r(),direction:Or});var jr=o({type:n("queryDataSource"),subscriptionId:r(),dataSourceId:Z,limit:O(),filter:a(Er),sorts:a(E(Br))}),Bn=r(),Rr=o({code:Bn,message:r(),isRetryable:b()}),Mr=v("status",[o({type:n("queryDataSourceResult"),subscriptionId:r(),status:n("success"),items:E(oe),hasMore:b()}),o({type:n("queryDataSourceResult"),subscriptionId:r(),status:n("error"),error:Rr})]),Dr=v("status",[o({type:n("queryDataSourceResult"),subscriptionId:r(),status:n("success"),items:E(d([oe,ir])),hasMore:b()}),o({type:n("queryDataSourceResult"),subscriptionId:r(),status:n("error"),error:Rr})]);var jn=r(),Rn=o({code:jn,message:r(),isRetryable:b()}),wr=o({type:n("openExternalUrl"),requestId:r(),url:r()}),Tr=v("status",[o({type:n("openExternalUrlResult"),requestId:r(),status:n("success")}),o({type:n("openExternalUrlResult"),requestId:r(),status:n("error"),error:Rn})]);var Re=o({object:n("page"),id:F,parent:re,properties:Be,created_time:a(r()),last_edited_time:a(r()),icon:a(Pe),cover:a(Ee),url:a(r()),public_url:a(r()),is_archived:b(),in_trash:b()});var Mn=r(),Ar=o({code:Mn,message:r(),isRetryable:b()}),Nr=v("status",[o({type:n("createPageResult"),requestId:r(),status:n("success"),page:oe}),o({type:n("createPageResult"),requestId:r(),status:n("error"),error:Ar})]),Ur=v("status",[o({type:n("createPageResult"),requestId:r(),status:n("success"),page:d([oe,Re])}),o({type:n("createPageResult"),requestId:r(),status:n("error"),error:Ar})]),Dn=v("type",[o({type:n("start")}),o({type:n("end")}),o({type:n("before"),blockId:le}),o({type:n("after"),blockId:le})]),Wa=v("type",[Ge,$e]),qr={type:n("createPage"),requestId:r(),properties:Be},Fr=v("type",[o({...qr,parent:Ge,position:a(Dn)}),o({...qr,parent:$e,position:a(mt())})]);var wn=r(),zr=o({code:wn,message:r(),isRetryable:b()}),Hr=o({type:n("getPage"),requestId:r(),pageId:F,dataSourceId:a(Z)}),Lr=v("status",[o({type:n("getPageResult"),requestId:r(),status:n("success"),page:oe}),o({type:n("getPageResult"),requestId:r(),status:n("error"),error:zr})]),Vr=v("status",[o({type:n("getPageResult"),requestId:r(),status:n("success"),page:d([oe,Re])}),o({type:n("getPageResult"),requestId:r(),status:n("error"),error:zr})]);var Tn=T(["side_peek","center_peek"]),qn=r(),An=o({code:qn,message:r(),isRetryable:b()}),Gr=o({type:n("openPage"),requestId:r(),pageId:F,mode:Tn}),$r=v("status",[o({type:n("openPageResult"),requestId:r(),status:n("success"),pageId:F}),o({type:n("openPageResult"),requestId:r(),status:n("error"),error:An})]);var Nn=r(),Qr=o({code:Nn,message:r(),isRetryable:b()}),Wr=v("status",[o({type:n("updatePageResult"),requestId:r(),status:n("success"),page:oe}),o({type:n("updatePageResult"),requestId:r(),status:n("error"),error:Qr})]),Xr=v("status",[o({type:n("updatePageResult"),requestId:r(),status:n("success"),page:d([oe,Re])}),o({type:n("updatePageResult"),requestId:r(),status:n("error"),error:Qr})]),Kr=o({type:n("updatePage"),requestId:r(),pageId:F,dataSourceId:a(Z),properties:a(Be),icon:a(Pe),cover:a(Ee),archived:a(b())});var Zr=o({type:n("currentUserChanged"),currentUser:ae});var Un=r(),Fn=o({code:Un,message:r(),isRetryable:b()}),Jr=o({type:n("getUser"),requestId:r(),userId:Qe}),Yr=v("status",[o({type:n("getUserResult"),requestId:r(),status:n("success"),user:ae}),o({type:n("getUserResult"),requestId:r(),status:n("error"),error:Fn})]);var eo=o({object:n("list"),results:E(ae),next_cursor:D(r()),has_more:b(),type:n("user"),user:$(r(),qe())});var zn=r(),Hn=o({code:zn,message:r(),isRetryable:b()}),to=o({type:n("listUsers"),requestId:r(),startCursor:a(r()),pageSize:a(O())}),ro=v("status",[o({type:n("listUsersResult"),requestId:r(),status:n("success"),list:eo}),o({type:n("listUsersResult"),requestId:r(),status:n("error"),error:Hn})]);var oo=o({type:n("invalidSandboxMessage"),reason:r()});var no=v("type",[We,Yt,Kt,Jt,Zt,Zr,er,Yr,ro,$r,Tr,oo]),io=v("type",[...no.options,Mr,Lr,Nr,Wr]),wu=v("type",[...no.options,Dr,Vr,Ur,Xr]);function so(e){return{...e,dataSources:{bindings:Object.fromEntries(Object.entries(e.dataSources.bindings).map(([t,i])=>[t,{...i,collectionSchema:{...i.collectionSchema,propertiesById:{...i.collectionSchema?.propertiesById,...Vt}}}]))}}}function ee(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function ze(e){return{...e,properties:Object.fromEntries(Object.entries(e.properties).map(([t,i])=>{switch(i?.type){case"unique_id":case"button":case"formula":case"location":case"rollup":case"verification":return[t,null];case"title":case"rich_text":case"number":case"url":case"email":case"phone_number":case"checkbox":case"select":case"status":case"multi_select":case"date":case"people":case"relation":case"files":case"place":case"created_time":case"last_edited_time":case"created_by":case"last_edited_by":case"last_visited_time":case void 0:return[t,i];default:return ee(i)}}))}}function ao(e){return{...e,properties:Object.fromEntries(Object.values(e.properties).flatMap(t=>t?[[t.id,t]]:[])),icon:e.icon??void 0,cover:e.cover??void 0,created_time:e.created_time??void 0,last_edited_time:e.last_edited_time??void 0,url:e.url??void 0,public_url:e.public_url??void 0}}function be(e){if(e==null||e==="")return;let t=new Date(e);if(Number.isFinite(t.getTime()))return{type:"datetime",start_date:t.toISOString().slice(0,10),start_time:t.toISOString().slice(11,16),time_zone:"UTC"}}var Se=class extends Error{};function St(e){try{return Ln(e)}catch(t){throw t instanceof RangeError?new Se(t.message):t}}function Ln(e){let{start:t,end:i,time_zone:s,reminder:c}=e;if(!t.split("T")[0])throw new Se("Date values must include a date.");let p=t.includes("T")||s!=null,f=t.match(/([+-])(\d{2}):(\d{2})$/),h=f?(Number(f[2])*60+Number(f[3]))*(f[1]==="-"?-1:1):0,y=s?.match(/^UTC(?:([+-])(\d{1,2})(?::(\d{2}))?)?$/),C=y?(Number(y[2]??0)*60+Number(y[3]??0))*(y[1]==="-"?-1:1):h,_=g=>{if(!g.split("T")[0])throw new Se("Date values must include a date.");if(!g.includes("T"))return{date:g,time:"00:00"};let N=g.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})(?::\d{2}(?:\.\d+)?)?$/);if(N)return{date:N[1],time:N[2]};if(!s||y){let U=new Date(new Date(g).getTime()+C*6e4).toISOString();return{date:U.slice(0,10),time:U.slice(11,16)}}let B=new Intl.DateTimeFormat("en-CA",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(g)),z=U=>B.find(te=>te.type===U)?.value;return{date:`${z("year")}-${z("month")}-${z("day")}`,time:`${z("hour")}:${z("minute")}`}},M=_(t),X=i?_(i):void 0;if(!p){if(c&&!("time"in c)&&c.unit!=="none")throw new Se("Hour and minute reminders require a date with a time.");return X?{type:"daterange",start_date:M.date,end_date:X.date,reminder:c}:{type:"date",start_date:M.date,reminder:c}}let V=s??(h===0?"UTC":`UTC${h<0?"-":"+"}${Math.floor(Math.abs(h)/60)}${Math.abs(h)%60===0?"":`:${String(Math.abs(h)%60).padStart(2,"0")}`}`);return X?{type:"datetimerange",start_date:M.date,start_time:M.time,end_date:X.date,end_time:X.time,time_zone:V,reminder:c}:{type:"datetime",start_date:M.date,start_time:M.time,time_zone:V,reminder:c}}function co(e){switch(e.type){case"title":return uo(e.title);case"rich_text":return uo(e.rich_text);case"number":return e.number??void 0;case"checkbox":return e.checkbox;case"url":return e.url??"";case"email":return e.email??"";case"phone_number":return e.phone_number??"";case"select":return e.select?.name;case"status":return e.status?.name;case"multi_select":return e.multi_select.flatMap(t=>t.name??[]);case"date":return e.date?St(e.date):void 0;case"people":return e.people.map(t=>t.object==="group"?{id:t.id,table:"space_permission_group",spaceId:t.id.split("|")[1]}:{id:t.id,table:"notion_user"});case"relation":return e.relation.map(t=>({id:t.id,table:"block"}));case"files":return e.files.map(t=>t.name).join(",");case"unique_id":return e.unique_id;case"button":return e.button;case"formula":return e.formula;case"location":return e.location;case"rollup":return e.rollup;case"verification":return e.verification;case"place":return"";case"created_time":return be(e.created_time);case"last_edited_time":return be(e.last_edited_time);case"last_visited_time":return be(e.last_visited_time);case"created_by":return e.created_by?[e.created_by]:void 0;case"last_edited_by":return e.last_edited_by?[e.last_edited_by]:void 0;default:return ee(e)}}function uo(e){return e.map(t=>{if(typeof t.plain_text=="string")return t.plain_text;let i=t.text;return i&&typeof i=="object"&&"content"in i&&typeof i.content=="string"?i.content:""}).join("")}function lo(e){let t={};for(let i of Object.values(e.properties))i&&(t[i.id]=co(i));return{id:e.id,is_archived:e.is_archived,in_trash:e.in_trash,propertiesById:{...t,created_time:be(e.created_time),last_edited_time:be(e.last_edited_time),created_by:e.created_by?[e.created_by]:void 0,last_edited_by:e.last_edited_by?[e.last_edited_by]:void 0}}}function po(e){return e.type==="queryDataSourceResult"?{...e,items:e.items.map(lo)}:{...e,page:ao(ze(e.page))}}function mo(e){return e.type==="queryDataSourceResult"?{...e,items:e.items.map(ze)}:{...e,page:ze(e.page)}}function fo(e,t){return e.type==="init"&&e.status==="success"||e.type==="dataSourcesChanged"?t<5?so(e):e:e.type!=="queryDataSourceResult"&&e.type!=="getPageResult"&&e.type!=="createPageResult"&&e.type!=="updatePageResult"||e.status==="error"?e:t<6?po(e):t<7?mo(e):e}var kt=o({theme:Ce,contrastMode:a(xe),blockId:le,parent:re,page:_e,manifest:de,dataSources:o({bindings:ye}),currentUser:ae}),yo=v("status",[o({status:n("success"),initialState:qt(kt,["manifest"])}),o({status:n("error"),error:Ne})]);var et=class{constructor(t){this.onUnsubscribe=t}onUnsubscribe;bySubscriptionId=new Map;subscribe(t){this.unsubscribe(t.subscriptionId);let i={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(t.subscriptionId,{message:t,token:i,isRefreshing:!0,shouldRefreshAgain:!1}),i}isCurrent(t,i){return this.bySubscriptionId.get(t)?.token===i}unsubscribe(t){this.bySubscriptionId.delete(t)&&this.onUnsubscribe(t)}refresh(t){let i=[],s=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===t){if(s=!0,c.isRefreshing){c.shouldRefreshAgain=!0;continue}c.isRefreshing=!0,i.push({message:c.message,token:c.token})}return s?i:void 0}finish(t,i){let s=this.bySubscriptionId.get(t);if(s?.token===i&&(s.isRefreshing=!1,!!s.shouldRefreshAgain))return s.shouldRefreshAgain=!1,s.isRefreshing=!0,{message:s.message,token:s.token}}unsubscribeAll(){for(let t of this.bySubscriptionId.keys())this.unsubscribe(t)}};function vo(e,t){if(e===void 0)return;let i="and"in e?e.and:[e];for(let s of i){let c=$n(s,t);if(c!==void 0)return c}}function $n(e,t){if(!Object.hasOwn(t.propertiesById,e.propertyId))return{code:"invalid_data_source_query_filter",message:`Data source query filter property ID "${e.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let i=t.propertiesById[e.propertyId],s=Object.keys(e).find(h=>h!=="propertyId");if(s!==i.type)return{code:"invalid_data_source_query_filter",message:`Data source query filter branch "${s}" does not match property type "${i.type}".`,isRetryable:!1};if("status"in e&&i.type==="status"){let h=e.status;if("group_equals"in h||"group_does_not_equal"in h){let y="group_equals"in h?h.group_equals:h.group_does_not_equal,_=(Array.isArray(y)?y:[y]).find(M=>!i.groups.some(X=>X.name===M));return _===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${_}".`,isRetryable:!1}}}if("relation"in e&&!Tt(Ye,e.relation))return{code:"invalid_data_source_query_filter",message:"Relation filters require a page ID.",isRetryable:!1};let c=Qn(e);if(c===void 0||i.type!==c.propertyType)return;let p=new Set(i.options.map(h=>h.name)),f=Wn(c.operator).find(h=>!p.has(h));if(f!==void 0)return{code:"invalid_data_source_query_filter",message:`Data source query filter option "${f}" is not defined for property "${e.propertyId}".`,isRetryable:!1}}function Qn(e){if("select"in e)return{propertyType:"select",operator:e.select};if("multi_select"in e)return{propertyType:"multi_select",operator:e.multi_select};if("status"in e){let t=e.status;return"group_equals"in t||"group_does_not_equal"in t?void 0:{propertyType:"status",operator:t}}}function Wn(e){let t;if("equals"in e)t=e.equals;else if("does_not_equal"in e)t=e.does_not_equal;else if("contains"in e)t=e.contains;else if("contains_all"in e)t=e.contains_all;else if("does_not_contain"in e)t=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:ee(e);return Array.isArray(t)?t:[t]}var Xn=new Set(Ht);function ho(e,t){if(e===void 0)return;if(e.length>bt)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${bt} entries.`,isRetryable:!1};let i=new Set;for(let s of e){if(i.has(s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sorts cannot contain duplicate property ID "${s.propertyId}".`,isRetryable:!1};if(i.add(s.propertyId),!Object.hasOwn(t.propertiesById,s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sort property ID "${s.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let c=t.propertiesById[s.propertyId];if(!Xn.has(c.type))return{code:"invalid_data_source_query_sort",message:`Data source query sorts do not yet support property type "${c.type}".`,isRetryable:!1}}}function go(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function It(e){let{currentBridgeProtocolVersion:t}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version: ${t}`,isRetryable:!1}}function bo(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function So(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function tt(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function _t(e){let{currentBridgeProtocolVersion:t,minBridgeProtocolVersion:i}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${t} is not supported. Minimum supported version is ${i}.`,isRetryable:!1}}function xt(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var Kn=5e3,Zn=5e3,Jn=5e3;function ko(e){let{manifestSource:t,prepareInit:i,sendInitMessage:s,warn:c,flushPendingHostStateChanges:p,minBridgeProtocolVersion:f,noConnectTimeoutMs:h=Kn,initialStateTimeoutMs:y=Zn,noInitResultTimeoutMs:C=Jn,stopHostWithFailure:_,onInitResult:M,onInitSent:X,onConnectionFailure:V}=e,g="waitingForConnect",N,B,z,U,te=!1,pe=!1;function K(){N!==void 0&&(window.clearTimeout(N),N=void 0)}function H(){B!==void 0&&(window.clearTimeout(B),B=void 0)}function Q(){z!==void 0&&(window.clearTimeout(z),z=void 0)}function G(k){let{initializationId:P,error:I,phase:ie,source:ot}=k;switch(g){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"failed":case"stopped":return;default:return ee(g)}g="failed",U=P,K(),H(),s({type:"init",initializationId:P,status:"error",error:I}),V({...I,phase:ie,source:ot})}async function ne(k){if(g==="waitingForConnect"){g="preparingInit",U=k.initializationId,K(),B=window.setTimeout(()=>{if(g!=="preparingInit")return;let P=go();c({...P,initializationId:k.initializationId}),G({initializationId:k.initializationId,error:P,phase:"init",source:"host"})},y);try{let P=await i(k);if(g!=="preparingInit")return;if(H(),P.status==="error"){G({initializationId:k.initializationId,error:P.error,phase:"init",source:"host"});return}g="waitingForInitResult";let I={type:"init",initializationId:k.initializationId,status:"success",theme:P.initialState.theme,contrastMode:P.initialState.contrastMode??Wt,blockId:P.initialState.blockId,parent:P.initialState.parent,page:P.initialState.page,currentUser:P.initialState.currentUser,manifest:P.initialState.manifest,dataSources:P.initialState.dataSources};if(s(I),g!=="waitingForInitResult"||(X(),g!=="waitingForInitResult"))return;z=window.setTimeout(()=>{if(g!=="waitingForInitResult")return;g="failed";let ie=So();V({...ie,phase:"initResult",source:"host"}),c({...ie,initializationId:k.initializationId})},C)}catch(P){if(g!=="preparingInit")return;c({message:"Failed to prepare custom block initialization",error:P}),G({initializationId:k.initializationId,error:tt(),phase:"init",source:"host"})}}}function q(k){if(g!=="stopped"&&g==="waitingForConnect"){if(!xt(k.bridgeProtocolVersion)){let P=It({currentBridgeProtocolVersion:k.bridgeProtocolVersion});G({initializationId:k.initializationId,error:P,phase:"connect",source:"host"});return}if(k.bridgeProtocolVersion<f){let P=_t({currentBridgeProtocolVersion:k.bridgeProtocolVersion,minBridgeProtocolVersion:f});G({initializationId:k.initializationId,error:P,phase:"connect",source:"host"});return}if(k.status==="error"&&(t==="sandbox"||k.error.code!=="manifest_invalid")){G({initializationId:k.initializationId,error:k.error,phase:"connect",source:"sandbox"});return}pe=!0,ne(k)}}function Y(k){if(g==="stopped"||g!=="waitingForConnect")return"handled";let{initializationId:P,bridgeProtocolVersion:I}=k;if(P===void 0)return"nack";let ie=k.error;return I!==void 0&&(xt(I)?I<f&&(ie=_t({currentBridgeProtocolVersion:I,minBridgeProtocolVersion:f})):ie=It({currentBridgeProtocolVersion:I})),G({initializationId:P,error:ie,phase:"connect",source:"host"}),"handled"}function me(k){let{initializationId:P,error:I}=k;g!=="waitingForInitResult"||P===void 0||P!==U||(K(),Q(),g="failed",c(I),V({...I,phase:"initResult",source:"host"}))}function He(){if(g!=="stopped"){if(te){_({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}te=!0,K(),g==="waitingForConnect"&&(N=window.setTimeout(()=>{if(g!=="waitingForConnect")return;g="failed";let k=bo();c(k),V({...k,phase:"connect",source:"host"})},h))}}function Me(k){if(g!=="waitingForInitResult"||k.initializationId!==U){c({message:"Ignored stale or unexpected initResult",payload:k});return}Q(),g=k.status==="success"?"initialized":"failed",k.status==="success"?p():V({...k.error,phase:"initResult",source:"sandbox"}),M(k)}function fe(){g="stopped",K(),H(),Q()}return{get status(){return g},get hasConnectedSandbox(){return pe},handleConnect:q,handleInitResult:Me,handleInvalidConnect:Y,handleInvalidInitResult:me,onIframeLoad:He,stop:fe}}function Ct(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function Pt(){return{code:"invalid_local_preview_url",message:"Local custom blocks require an HTTP(S) URL on localhost, a .localhost subdomain, or 127.0.0.1, without credentials and on a different origin from the host.",isRetryable:!1}}function Io(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function _o(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function xo(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function Co(e){return(e.protocol==="http:"||e.protocol==="https:")&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname.endsWith(".localhost"))&&e.username===""&&e.password===""}function rt({url:e,hostOrigin:t}){return typeof t=="string"&&t!==""&&e.origin!==t&&Co(e)}async function Po(e){return e.manifestSource==="host"?e.hostManifest:e.connectManifest!==void 0?{status:"success",manifest:e.connectManifest}:{status:"error",error:{code:"manifest_unavailable",message:"The sandbox did not provide a manifest in connect.",isRetryable:!1}}}var Eo=v("status",[o({status:n("success"),manifest:de}),o({status:n("error"),error:Ne})]);function Oo(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var Bo=o({type:n("resize"),height:A(O(),De(),Te(0))});var jo=o({type:n("unsubscribeDataSourceQuery"),subscriptionId:r()});var Ro=o({code:r(),message:r(),isRetryable:b()});var Mo={type:n("connect"),initializationId:r(),bridgeProtocolVersion:O(),sdkVersion:r()},Do=v("status",[o({status:n("success"),manifest:a(de),...Mo}),o({status:n("error"),error:Ro,...Mo})]);var Yn=r(),ei=o({code:Yn,message:r(),isRetryable:b()}),wo=v("status",[o({type:n("initResult"),initializationId:r(),status:n("success"),initialHeight:a(A(O(),De(),Te(0)))}),o({type:n("initResult"),initializationId:r(),status:n("error"),error:ei})]);var To=o({type:n("invalidHostMessage"),reason:r()});var qo=v("type",[Do,wo,jr,jo,Fr,Hr,Jr,to,Gr,wr,Kr,Bo,To]);function Ao(e){return Ie(qo,e)}function No(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function Uo(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function Fo(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}function zo(e){let t=Fo(e);return t==="invalidHostMessage"||t==="invalidSandboxMessage"?{incomingType:t}:{incomingType:t,nack:{type:"invalidSandboxMessage",reason:ti(t)}}}function ti(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var Ho=o({initializationId:r()}),ri=o({bridgeProtocolVersion:d([O(),pt()])});function Lo(e){let{iframe:t,sandboxOrigin:i,getInitStatus:s,emit:c,sendNack:p,onInvalidConnect:f,onInvalidInitResult:h,onConnect:y,onInitResult:C,onQueryDataSource:_,onUnsubscribeDataSourceQuery:M,onCreatePage:X,onGetPage:V,onOpenPage:g,onOpenExternalUrl:N,onGetUser:B,onListUsers:z,onUpdatePage:U,onResize:te}=e;function pe(K,H){c("warn",{message:"Ignored unsupported sandbox message",payload:Et(K),issues:H});let Q=zo(K);if(Q.incomingType==="connect"){let G=Ie(Ho,K),ne=Ie(ri,K);if(f({initializationId:G.success?G.output.initializationId:void 0,error:No(),bridgeProtocolVersion:ne.success?ne.output.bridgeProtocolVersion:void 0})==="handled")return}if(Q.incomingType==="initResult"){let G=Ie(Ho,K);h({initializationId:G.success?G.output.initializationId:void 0,error:Uo()})}Q.nack!==void 0&&s()!=="stopped"&&p(Q.nack)}return function(H){let Q=H.source===t.contentWindow,G=H.origin===i;if(!Q||!G)return;let ne=Ao(H.data);if(!ne.success){pe(H.data,ne.issues);return}let q=ne.output;if(!Oo(q)&&s()!=="initialized"){c("warn",{message:`Ignored ${q.type} before initialization completed`,payload:Et(q)});return}switch(c("in",Et(q)),q.type){case"connect":y(q);return;case"initResult":C(q);return;case"queryDataSource":_(q);return;case"unsubscribeDataSourceQuery":M(q);return;case"createPage":X(q);return;case"openPage":g(q);return;case"openExternalUrl":N(q);return;case"getPage":V(q);return;case"getUser":B(q);return;case"listUsers":z(q);return;case"updatePage":U(q);return;case"resize":te(q);return;case"invalidHostMessage":return;default:ee(q)}}}function Et(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="openExternalUrl"?{type:"openExternalUrl",..."requestId"in e?{requestId:e.requestId}:{}}:e}function Vo(e){if(e.length>2048||!URL.canParse(e))return;let t=new URL(e);if(!(t.protocol!=="http:"&&t.protocol!=="https:"||t.username!==""||t.password!==""||t.href.length>2048))return t.href}var $o=5;function ni(e){let{iframe:t,prepareInitialState:i,handlers:s,onStatusChange:c,onLog:p,onQueryUnsubscribed:f,minBridgeProtocolVersion:h,noConnectTimeoutMs:y,initialStateTimeoutMs:C,noInitResultTimeoutMs:_}=e,M=ii(e.sandboxUrl,e.manifestSource),X=M.origin,V=Math.max(h??3,3),g=new AbortController,N,B={},z=!1,U=new AbortController,te,pe,K=8,H=new et(u=>{f?.(u)});function Q(u,S){p?.(u,S)}function G(u){let S=I.status;switch(S){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"failed":break;case"stopped":return;default:return ee(S)}let x=fo(u,K);Q("out",x),t.contentWindow?.postMessage(x,X)}function ne(u){G(se(We,u))}function q(u){G(u)}function Y(u){let S=I.status;switch(S){case"initialized":G(se(io,u));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"failed":case"stopped":return;default:ee(S)}}async function me(u,S){if(S===void 0)return;let x=await S(u);Y({type:`${u.type}Result`,requestId:u.requestId,...x})}function He(u){let S=u.response.status==="error"?{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"error",error:u.response.error}:{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"success",items:u.response.items,hasMore:u.response.hasMore};Y(S)}async function Me(u,S=H.subscribe(u)){try{let x=si(pe,u.dataSourceId),ve=ai(u,x);if(ve!==void 0){H.isCurrent(u.subscriptionId,S)&&(H.unsubscribe(u.subscriptionId),He({subscriptionId:u.subscriptionId,response:{status:"error",error:ve}}));return}let it=await s.queryDataSource(u);if(!H.isCurrent(u.subscriptionId,S))return;it.status==="error"&&!it.error.isRetryable&&H.unsubscribe(u.subscriptionId),He({subscriptionId:u.subscriptionId,response:it})}finally{let x=H.finish(u.subscriptionId,S);x!==void 0&&Me(x.message,x.token)}}function fe(u){I.status==="stopped"||I.status==="failed"||(Object.assign(B,u),P())}async function k(u){if(s.openExternalUrl===void 0||g.signal.aborted||N===u.requestId)return;if(N!==void 0){let x={type:"openExternalUrlResult",requestId:u.requestId,status:"error",error:{code:"pending_navigation",message:"Another external navigation request is pending.",isRetryable:!0}};Y(x);return}let S=Vo(u.url);if(S===void 0){let x={type:"openExternalUrlResult",requestId:u.requestId,status:"error",error:{code:"invalid_url",message:"Only valid HTTP or HTTPS URLs without credentials, up to 2,048 characters, can be opened.",isRetryable:!1}};Y(x);return}N=u.requestId;try{let x=await s.openExternalUrl({...u,url:S},{signal:g.signal});if(g.signal.aborted)return;let ve={type:"openExternalUrlResult",requestId:u.requestId,...x};Y(ve)}catch(x){if(!g.signal.aborted)throw x}finally{N===u.requestId&&(N=void 0)}}function P(){if(I.status!=="initialized")return;let u=B;B={},u.theme!==void 0&&Y({type:"themeChanged",theme:u.theme}),u.contrastMode!==void 0&&Y({type:"contrastModeChanged",contrastMode:u.contrastMode}),u.parent!==void 0&&Y({type:"parentChanged",parent:u.parent}),u.page!==void 0&&Y({type:"pageChanged",page:u.page}),u.dataSources!==void 0&&Y({type:"dataSourcesChanged",dataSources:u.dataSources}),u.currentUser!==void 0&&Y({type:"currentUserChanged",currentUser:u.currentUser})}let I=ko({manifestSource:e.manifestSource,async prepareInit(u){let S=u.status==="success"?u.manifest:void 0;K=u.bridgeProtocolVersion,c({status:"preparingInit",localManifest:rt({url:M,hostOrigin:window.location.origin})?S:void 0,bridgeProtocolVersion:u.bridgeProtocolVersion,sdkVersion:u.sdkVersion});let x=await(Xo??Bt(S));return I.status!=="preparingInit"?x:ie(x)},sendInitMessage:ne,onInitSent:()=>c({status:"waitingForInitResult"}),warn:u=>Q("warn",u),flushPendingHostStateChanges:P,minBridgeProtocolVersion:V,noConnectTimeoutMs:y,initialStateTimeoutMs:C,noInitResultTimeoutMs:_,stopHostWithFailure:Rt,onInitResult(u){u.status==="success"&&te!==void 0&&c({status:"initialized",resolvedManifest:te,initialHeight:u.initialHeight})},onConnectionFailure:u=>{U.abort(),c({status:"failed",error:u})}});function ie(u){if(u.status==="error")return u;let S=se(kt,{...u.initialState,...B});if(te=S.manifest,B={},K<$o&&S.page.type==="unavailable")return{status:"error",error:Ct()};let x=Qo(S.manifest,S.dataSources);return x!==void 0?{status:"error",error:x}:(pe=S.dataSources,z=!0,{status:"success",initialState:S})}let ot=Ko().catch(Ot),Xo=e.manifestSource==="host"?Bt(void 0).catch(Ot):void 0;async function Ko(){U.signal.throwIfAborted();let u=await e.getPersistedManifest({signal:U.signal});return U.signal.throwIfAborted(),se(Eo,u)}function Ot(u){return U.signal.aborted||Q("warn",{message:"Failed to prepare custom block initialization",error:u}),{status:"error",error:tt()}}async function Bt(u){U.signal.throwIfAborted();let S=await Po({manifestSource:e.manifestSource,hostManifest:ot,connectManifest:u});if(U.signal.throwIfAborted(),S.status==="error")return S;let x=se(yo,await i({manifest:S.manifest,signal:U.signal}));return x.status==="error"?x:{status:"success",initialState:{...x.initialState,manifest:S.manifest}}}let jt=Lo({iframe:t,sandboxOrigin:X,getInitStatus:()=>I.status,emit:Q,sendNack:q,onInvalidConnect:I.handleInvalidConnect,onInvalidInitResult:I.handleInvalidInitResult,onConnect:I.handleConnect,onInitResult:I.handleInitResult,onQueryDataSource:Me,onUnsubscribeDataSourceQuery:u=>H.unsubscribe(u.subscriptionId),onOpenExternalUrl:k,onCreatePage:u=>me(u,s.createPage),onGetPage:u=>me(u,s.getPage),onOpenPage:u=>me(u,s.openPage),onGetUser:u=>me(u,s.getUser),onListUsers:u=>me(u,s.listUsers),onUpdatePage:u=>me(u,s.updatePage),onResize:u=>s.resize?.(u)});window.addEventListener("message",jt),t.addEventListener("load",I.onIframeLoad);function nt(){g.abort(),U.abort(),window.removeEventListener("message",jt),t.removeEventListener("load",I.onIframeLoad),I.stop(),H.unsubscribeAll()}function Zo(){let u=I.status;nt(),u!=="stopped"&&u!=="failed"&&c({status:"stopped"})}function Rt(u){if(I.status!=="stopped"){if(I.status==="failed"){nt();return}nt(),Q("warn",u),c({status:"failed",error:u})}}return c({status:"waitingForConnect"}),{stop:Zo,setTheme(u){fe({theme:u})},setContrastMode(u){fe({contrastMode:u})},setParent(u){fe({parent:u})},setPage(u){if(u.type==="unavailable"&&K<$o&&(I.status==="preparingInit"&&z||I.status==="waitingForInitResult"||I.status==="initialized")){Rt({...Ct(),phase:"runtime",source:"host"});return}fe({page:u})},setCurrentUser(u){fe({currentUser:u})},setDataSources(u){let S={bindings:se(ye,u.bindings)},x=I.hasConnectedSandbox&&te!==void 0?Qo(te,S):void 0;return x!==void 0?(Q("warn",{message:"Ignored invalid data source bindings update",payload:S}),{status:"error",error:x}):(pe=S,fe({dataSources:S}),{status:"success"})},refreshQuery({dataSourceId:u}){if(I.status!=="initialized")return;let S=se(Z,u),x=H.refresh(S);if(x===void 0){Q("warn",`No active query exists for data source "${u}"`);return}for(let ve of x)Me(ve.message,ve.token)}}}function ii(e,t){let i;try{i=new URL(e)}catch(s){throw t==="host"?s:new Ae(Pt())}if(t==="sandbox"&&!rt({url:i,hostOrigin:window.location.origin}))throw new Ae(Pt());return i}function si(e,t){return Object.values(e?.bindings??{}).find(i=>i.collectionPointer?.id===t)?.collectionSchema}function Qo(e,t){for(let[i,s]of Object.entries(e.dataSources)){let c=t.bindings[i];if(c?.inaccessible===!0)continue;let p=Qt({manifestDataSource:s,collectionSchema:c?.collectionSchema,propertyIdsByKey:c?.propertyIdsByKey});if(c?.collectionPointer===void 0||p.status==="missing_schema")return _o();for(let f of p.properties){if(f.status==="missing")return xo();if(f.status!=="mapped")return Io()}}}function ai(e,t){return t===void 0?e.filter===void 0&&(e.sorts?.length??0)===0?void 0:{code:"data_source_schema_unavailable",message:"You cannot query this data source with filters or sorts because its schema is unavailable.",isRetryable:!1}:vo(e.filter,t)??ho(e.sorts,t)}function ui(e){let{manifestProperties:t,propertySchemasById:i}=e,s=[];for(let[c,p]of Object.entries(t)){let f=ci({propertyKey:c,manifestProperty:p,propertySchemasById:i});f!==void 0&&s.push([c,f])}return Object.fromEntries(s)}function ci(e){let{propertyKey:t,manifestProperty:i,propertySchemasById:s}=e,c=Wo(i.name),p=Object.entries(s).filter(([f,h])=>h.type===i.type&&(f===t||Wo(h.name)===c));return p.length===1?p[0][0]:void 0}function Wo(e){return e.trim().toLowerCase()}function li(e){return se(F,e)}export{Se as InvalidNotionDateError,ni as createCustomBlockHost,ui as getAutoBoundPropertyIdsByKey,rt as isAllowedLocalPreviewUrl,St as toNotionDateValue,li as toNotionPageId};
|
|
1
|
+
var Ve,mn={lang:void 0,message:void 0,abortEarly:void 0,abortPipeEarly:void 0};function ut(e){return!e&&!Ve?mn:{lang:e?.lang??Ve?.lang,message:e?.message,abortEarly:e?.abortEarly??Ve?.abortEarly,abortPipeEarly:e?.abortPipeEarly??Ve?.abortPipeEarly}}var fn;function yn(e){return fn?.get(e)}var dn;function vn(e){return dn?.get(e)}var hn;function gn(e,t){return hn?.get(e)?.get(t)}function xe(e){let t=typeof e;return t==="string"?`"${e}"`:t==="number"||t==="bigint"||t==="boolean"?`${e}`:t==="object"||t==="function"?(e&&Object.getPrototypeOf(e)?.constructor?.name)??"null":t}function M(e,t,o,s,c){let l=c&&"input"in c?c.input:o.value,p=c?.expected??e.expects??null,h=c?.received??xe(l),y={kind:e.kind,type:e.type,input:l,expected:p,received:h,message:`Invalid ${t}: ${p?`Expected ${p} but r`:"R"}eceived ${h}`,requirement:e.requirement,path:c?.path,issues:c?.issues,lang:s.lang,abortEarly:s.abortEarly,abortPipeEarly:s.abortPipeEarly},x=e.kind==="schema",k=c?.message??e.message??gn(e.reference,y.lang)??(x?vn(y.lang):null)??s.message??yn(y.lang);k!==void 0&&(y.message=typeof k=="function"?k(y):k),x&&(o.typed=!1),o.issues?o.issues.push(y):o.issues=[y]}function bn(e,t){return e===t||Number.isNaN(e)&&Number.isNaN(t)}function Ft(e,t){return Object.prototype.hasOwnProperty.call(e,t)&&t!=="__proto__"&&t!=="prototype"&&t!=="constructor"}function ct(e,t){let o=[...new Set(e)];return o.length>1?`(${o.join(` ${t} `)})`:o[0]??"never"}function $(e){return e["~standard"]={version:1,vendor:"valibot",validate:t=>e["~run"]({value:t},ut())},e}var Sn=class extends Error{constructor(e){super(e[0].message),this.name="ValiError",this.issues=e}};function me(e){return{kind:"transformation",type:"brand",reference:me,async:!1,name:e,"~run"(t){return t}}}function Te(e){return{kind:"validation",type:"finite",reference:Te,async:!1,expects:null,requirement:Number.isFinite,message:e,"~run"(t,o){return t.typed&&!this.requirement(t.value)&&M(this,"finite",t,o),t}}}function lt(e,t){let o=xe(e);return{kind:"validation",type:"includes",reference:lt,async:!1,expects:o,requirement:e,message:t,"~run"(s,c){return s.typed&&!s.value.includes(this.requirement)&&M(this,"content",s,c,{received:`!${o}`}),s}}}function qe(e,t){return{kind:"validation",type:"max_length",reference:qe,async:!1,expects:`<=${e}`,requirement:e,message:t,"~run"(o,s){return o.typed&&o.value.length>this.requirement&&M(this,"length",o,s,{received:`${o.value.length}`}),o}}}function be(e,t){return{kind:"validation",type:"min_length",reference:be,async:!1,expects:`>=${e}`,requirement:e,message:t,"~run"(o,s){return o.typed&&o.value.length<this.requirement&&M(this,"length",o,s,{received:`${o.value.length}`}),o}}}function Ae(e,t){return{kind:"validation",type:"min_value",reference:Ae,async:!1,expects:`>=${e instanceof Date?e.toJSON():xe(e)}`,requirement:e,message:t,"~run"(o,s){return o.typed&&!(o.value>=this.requirement)&&M(this,"value",o,s,{received:o.value instanceof Date?o.value.toJSON():xe(o.value)}),o}}}function pt(e,t){return{kind:"validation",type:"regex",reference:pt,async:!1,expects:`${e}`,requirement:e,message:t,"~run"(o,s){return o.typed&&!this.requirement.test(o.value)&&M(this,"format",o,s),o}}}function mt(e){return{kind:"transformation",type:"transform",reference:mt,async:!1,operation:e,"~run"(t){return t.value=this.operation(t.value),t}}}var zt={abortEarly:!0};function ft(e,t,o){return typeof e.fallback=="function"?e.fallback(t,o):e.fallback}function Ne(e,t,o){return typeof e.default=="function"?e.default(t,o):e.default}function Ht(e,t){return!e["~run"]({value:t},zt).issues}function O(e,t){return $({kind:"schema",type:"array",reference:O,expects:"Array",async:!1,item:e,message:t,"~run"(o,s){let c=o.value;if(Array.isArray(c)){o.typed=!0,o.value=[];for(let l=0;l<c.length;l++){let p=c[l],h=this.item["~run"]({value:p},s);if(h.issues){let y={type:"array",origin:"value",input:c,key:l,value:p};for(let x of h.issues)x.path?x.path.unshift(y):x.path=[y],o.issues?.push(x);if(o.issues||(o.issues=h.issues),s.abortEarly){o.typed=!1;break}}h.typed||(o.typed=!1),o.value.push(h.value)}}else M(this,"type",o,s);return o}})}function g(e){return $({kind:"schema",type:"boolean",reference:g,expects:"boolean",async:!1,message:e,"~run"(t,o){return typeof t.value=="boolean"?t.typed=!0:M(this,"type",t,o),t}})}function i(e,t){return $({kind:"schema",type:"literal",reference:i,expects:xe(e),async:!1,literal:e,message:t,"~run"(o,s){return bn(o.value,this.literal)?o.typed=!0:M(this,"type",o,s),o}})}function Ge(e,t){return $({kind:"schema",type:"loose_object",reference:Ge,expects:"Object",async:!1,entries:e,message:t,"~run"(o,s){let c=o.value;if(c&&typeof c=="object"){o.typed=!0,o.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let h=l in c?c[l]:Ne(p),y=p["~run"]({value:h},s);if(y.issues){let x={type:"object",origin:"value",input:c,key:l,value:h};for(let k of y.issues)k.path?k.path.unshift(x):k.path=[x],o.issues?.push(k);if(o.issues||(o.issues=y.issues),s.abortEarly){o.typed=!1;break}}y.typed||(o.typed=!1),o.value[l]=y.value}else if(p.fallback!==void 0)o.value[l]=ft(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(M(this,"key",o,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}if(!o.issues||!s.abortEarly)for(let l in c)Ft(c,l)&&!Object.prototype.hasOwnProperty.call(this.entries,l)&&(o.value[l]=c[l])}else M(this,"type",o,s);return o}})}function yt(e){return $({kind:"schema",type:"nan",reference:yt,expects:"NaN",async:!1,message:e,"~run"(t,o){return Number.isNaN(t.value)?t.typed=!0:M(this,"type",t,o),t}})}function dt(e){return $({kind:"schema",type:"never",reference:dt,expects:"never",async:!1,message:e,"~run"(t,o){return M(this,"type",t,o),t}})}function q(e,t){return $({kind:"schema",type:"nullable",reference:q,expects:`(${e.expects} | null)`,async:!1,wrapped:e,default:t,"~run"(o,s){return o.value===null&&(this.default!==void 0&&(o.value=Ne(this,o,s)),o.value===null)?(o.typed=!0,o):this.wrapped["~run"](o,s)}})}function R(e){return $({kind:"schema",type:"number",reference:R,expects:"number",async:!1,message:e,"~run"(t,o){return typeof t.value=="number"&&!isNaN(t.value)?t.typed=!0:M(this,"type",t,o),t}})}function n(e,t){return $({kind:"schema",type:"object",reference:n,expects:"Object",async:!1,entries:e,message:t,"~run"(o,s){let c=o.value;if(c&&typeof c=="object"){o.typed=!0,o.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let h=l in c?c[l]:Ne(p),y=p["~run"]({value:h},s);if(y.issues){let x={type:"object",origin:"value",input:c,key:l,value:h};for(let k of y.issues)k.path?k.path.unshift(x):k.path=[x],o.issues?.push(k);if(o.issues||(o.issues=y.issues),s.abortEarly){o.typed=!1;break}}y.typed||(o.typed=!1),o.value[l]=y.value}else if(p.fallback!==void 0)o.value[l]=ft(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(M(this,"key",o,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}}else M(this,"type",o,s);return o}})}function a(e,t){return $({kind:"schema",type:"optional",reference:a,expects:`(${e.expects} | undefined)`,async:!1,wrapped:e,default:t,"~run"(o,s){return o.value===void 0&&(this.default!==void 0&&(o.value=Ne(this,o,s)),o.value===void 0)?(o.typed=!0,o):this.wrapped["~run"](o,s)}})}function B(e,t){return $({kind:"schema",type:"picklist",reference:B,expects:ct(e.map(xe),"|"),async:!1,options:e,message:t,"~run"(o,s){return this.options.includes(o.value)?o.typed=!0:M(this,"type",o,s),o}})}function Q(e,t,o){return $({kind:"schema",type:"record",reference:Q,expects:"Object",async:!1,key:e,value:t,message:o,"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){s.typed=!0,s.value={};for(let p in l)if(Ft(l,p)){let h=l[p],y=this.key["~run"]({value:p},c);if(y.issues){let k={type:"object",origin:"key",input:l,key:p,value:h};for(let T of y.issues)T.path=[k],s.issues?.push(T);if(s.issues||(s.issues=y.issues),c.abortEarly){s.typed=!1;break}}let x=this.value["~run"]({value:h},c);if(x.issues){let k={type:"object",origin:"value",input:l,key:p,value:h};for(let T of x.issues)T.path?T.path.unshift(k):T.path=[k],s.issues?.push(T);if(s.issues||(s.issues=x.issues),c.abortEarly){s.typed=!1;break}}(!y.typed||!x.typed)&&(s.typed=!1),y.typed&&(s.value[y.value]=x.value)}}else M(this,"type",s,c);return s}})}function m(e,t){return $({kind:"schema",type:"strict_object",reference:m,expects:"Object",async:!1,entries:e,message:t,"~run"(o,s){let c=o.value;if(c&&typeof c=="object"){o.typed=!0,o.value={};for(let l in this.entries){let p=this.entries[l];if(l in c||(p.type==="exact_optional"||p.type==="optional"||p.type==="nullish")&&p.default!==void 0){let h=l in c?c[l]:Ne(p),y=p["~run"]({value:h},s);if(y.issues){let x={type:"object",origin:"value",input:c,key:l,value:h};for(let k of y.issues)k.path?k.path.unshift(x):k.path=[x],o.issues?.push(k);if(o.issues||(o.issues=y.issues),s.abortEarly){o.typed=!1;break}}y.typed||(o.typed=!1),o.value[l]=y.value}else if(p.fallback!==void 0)o.value[l]=ft(p);else if(p.type!=="exact_optional"&&p.type!=="optional"&&p.type!=="nullish"&&(M(this,"key",o,s,{input:void 0,expected:`"${l}"`,path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]}),s.abortEarly))break}if(!o.issues||!s.abortEarly){for(let l in c)if(!Object.prototype.hasOwnProperty.call(this.entries,l)){M(this,"key",o,s,{input:l,expected:"never",path:[{type:"object",origin:"key",input:c,key:l,value:c[l]}]});break}}}else M(this,"type",o,s);return o}})}function r(e){return $({kind:"schema",type:"string",reference:r,expects:"string",async:!1,message:e,"~run"(t,o){return typeof t.value=="string"?t.typed=!0:M(this,"type",t,o),t}})}function Ut(e){let t;if(e)for(let o of e)if(t)for(let s of o.issues)t.push(s);else t=o.issues;return t}function d(e,t){return $({kind:"schema",type:"union",reference:d,expects:ct(e.map(o=>o.expects),"|"),async:!1,options:e,message:t,"~run"(o,s){let c,l,p;for(let h of this.options){let y=h["~run"]({value:o.value},s);if(y.typed)if(y.issues)l?l.push(y):l=[y];else{c=y;break}else p?p.push(y):p=[y]}if(c)return c;if(l){if(l.length===1)return l[0];M(this,"type",o,s,{issues:Ut(l)}),o.typed=!0}else{if(p?.length===1)return p[0];M(this,"type",o,s,{issues:Ut(p)})}return o}})}function Se(){return $({kind:"schema",type:"unknown",reference:Se,expects:"unknown",async:!1,"~run"(e){return e.typed=!0,e}})}function v(e,t,o){return $({kind:"schema",type:"variant",reference:v,expects:"Object",async:!1,key:e,options:t,message:o,"~run"(s,c){let l=s.value;if(l&&typeof l=="object"){let p,h=0,y=this.key,x=[],k=(T,W)=>{for(let V of T.options){if(V.type==="variant")k(V,new Set(W).add(V.key));else{let b=!0,N=0;for(let j of W){let H=V.entries[j];if(j in l?H["~run"]({typed:!1,value:l[j]},zt).issues:H.type!=="exact_optional"&&H.type!=="optional"&&H.type!=="nullish"){b=!1,y!==j&&(h<N||h===N&&j in l&&!(y in l))&&(h=N,y=j,x=[]),y===j&&x.push(V.entries[j].expects);break}N++}if(b){let j=V["~run"]({value:l},c);(!p||!p.typed&&j.typed)&&(p=j)}}if(p&&!p.issues)break}};if(k(this,new Set([this.key])),p)return p;M(this,"type",s,c,{input:l[y],expected:ct(x,"|"),path:[{type:"object",origin:"value",input:l,key:y,value:l[y]}]})}else M(this,"type",s,c);return s}})}function Lt(e,t){let o={...e.entries};for(let s of t)delete o[s];return $({...e,entries:o})}function ue(e,t,o){let s=e["~run"]({value:t},ut(o));if(s.issues)throw new Sn(s.issues);return s.value}function A(...e){return $({...e[0],pipe:e,"~run"(t,o){for(let s of e)if(s.kind!=="metadata"){if(t.issues&&(s.kind==="schema"||s.kind==="transformation")){t.typed=!1;break}(!t.issues||!o.abortEarly&&!o.abortPipeEarly)&&(t=s["~run"](t,o))}return t}})}function ie(e,t,o){let s=e["~run"]({value:t},ut(o));return{typed:s.typed,success:!s.issues,output:s.value,issues:s.issues}}var fe=A(r(),me("NotionBlockId")),K=A(r(),me("NotionDataSourceId")),z=A(r(),me("NotionPageId")),Vt=A(r(),me("NotionAgentId")),Gt=A(r(),me("NotionSpaceId"));var $t=n({id:K,table:r(),spaceId:a(Gt)});var Qt=B(["default","gray","brown","orange","yellow","green","blue","purple","pink","red","gray_background","brown_background","orange_background","yellow_background","green_background","blue_background","purple_background","pink_background","red_background","default_background"]),vt=n({id:r(),name:r(),color:a(Qt),description:a(r())}),kn=n({id:r(),name:r(),color:a(Qt),option_ids:O(r())}),In=n({synced_property_id:r(),synced_property_name:r()}),D=n({name:r(),description:a(r())}),_n=["title","rich_text","number","checkbox","url","email","phone_number","select","multi_select","status","date","people","files","unique_id","relation","place","formula","rollup","button","verification","last_visited_time","location","created_time","last_edited_time","created_by","last_edited_by"],Wt=B(_n),Xt=["title","rich_text","number","checkbox","url","email","phone_number","date","created_time","last_edited_time","people","created_by"],Kt=v("type",[n({...D.entries,type:i("title")}),n({...D.entries,type:i("rich_text")}),n({...D.entries,type:i("number")}),n({...D.entries,type:i("checkbox")}),n({...D.entries,type:i("url")}),n({...D.entries,type:i("email")}),n({...D.entries,type:i("phone_number")}),n({...D.entries,type:i("select"),options:O(vt)}),n({...D.entries,type:i("multi_select"),options:O(vt)}),n({...D.entries,type:i("status"),options:O(vt),groups:O(kn)}),n({...D.entries,type:i("date")}),n({...D.entries,type:i("people")}),n({...D.entries,type:i("files")}),n({...D.entries,type:i("unique_id")}),n({...D.entries,type:i("relation"),data_source_id:a(r()),dual_property:a(In)}),n({...D.entries,type:i("place")}),n({...D.entries,type:i("formula")}),n({...D.entries,type:i("rollup")}),n({...D.entries,type:i("button")}),n({...D.entries,type:i("verification")}),n({...D.entries,type:i("last_visited_time")}),n({...D.entries,type:i("location")}),n({...D.entries,type:i("created_time")}),n({...D.entries,type:i("last_edited_time")}),n({...D.entries,type:i("created_by")}),n({...D.entries,type:i("last_edited_by")})]);var Zt={created_time:{type:"created_time",name:"Created time"},last_edited_time:{type:"last_edited_time",name:"Last edited time"},created_by:{type:"created_by",name:"Created by"},last_edited_by:{type:"last_edited_by",name:"Last edited by"}};var Jt=n({id:a(K),propertiesById:Q(r(),Kt)});var Yt=n({collectionPointer:a($t),collectionSchema:a(Jt),propertyIdsByKey:a(Q(r(),a(r()))),inaccessible:a(i(!0))});var ve=Q(r(),Yt);function er(e){let t=Object.entries(e.manifestDataSource.properties??{}).map(([o,s])=>{let c=e.propertyIdsByKey?.[o],l=c===void 0?void 0:e.collectionSchema?.propertiesById[c];return xn(o,c,l?.type,s.type)});return e.collectionSchema===void 0?{status:"missing_schema",properties:t}:t.every(o=>o.status==="mapped")?{status:"complete",properties:t}:{status:"incomplete",properties:t}}function xn(e,t,o,s){return t===void 0?{status:"missing",propertyKey:e,propertyId:t}:o===void 0?{status:"invalid",propertyKey:e,propertyId:t}:{status:o===s?"mapped":"incompatible",propertyKey:e,propertyId:t}}var $e=n({type:i("page_id"),page_id:z}),Qe=n({type:i("data_source_id"),data_source_id:K}),Cn=n({type:i("workspace"),workspace:i(!0)}),Pn=n({type:i("block_id"),block_id:fe}),En=n({type:i("agent_id"),agent_id:Vt}),On=n({type:i("unavailable")}),re=v("type",[$e,Qe,Cn,Pn,En,On]);var Ce=v("type",[n({type:i("unavailable")}),n({type:i("page"),id:z,parent:re})]);var Pe=B(["standard","high"]),tr="standard";var Ee=B(["light","dark"]);var rr=n({capability:r(),resource:r()});var Rn=v("type",[n({type:i("emoji"),emoji:r()}),n({type:i("external"),url:r()})]),Bn=n({name:r(),description:a(r()),type:Wt}),jn=n({name:r(),description:a(r()),icon:a(Rn),properties:a(Q(r(),Bn),{})}),he=n({version:i(1),name:a(r()),description:a(r()),slashCommand:a(r()),icon:a(n({type:i("emoji"),emoji:r()})),dataSources:a(Q(r(),jn),{}),capabilities:a(O(rr))});var We=A(r(),me("NotionUserId"));var ce=n({object:i("user"),id:We,name:a(r()),avatar_url:q(r()),type:i("person"),person:n({email:r()})});var Mn=r(),Fe=n({code:Mn,message:r(),isRetryable:g()}),Ue=class extends Error{constructor(t){super(t.message),this.name="CustomBlockInitializationError",this.code=t.code,this.isRetryable=t.isRetryable}code;isRetryable},Xe=v("status",[n({type:i("init"),initializationId:r(),status:i("success"),theme:Ee,contrastMode:Pe,blockId:fe,parent:re,page:Ce,manifest:he,dataSources:n({bindings:ve}),currentUser:ce}),n({type:i("init"),initializationId:r(),status:i("error"),error:Fe})]);var or=n({type:i("contrastModeChanged"),contrastMode:Pe});var nr=n({type:i("pageChanged"),page:Ce});var ir=n({type:i("parentChanged"),parent:re});var sr=n({type:i("themeChanged"),theme:Ee});var ar=n({type:i("dataSourcesChanged"),dataSources:n({bindings:ve})});var Ke=n({unit:B(["year","month","week","day"]),value:R(),time:r(),defaultTimeZone:a(r())}),Dn=n({unit:B(["hour","minute"]),value:R()}),ze=n({unit:i("none")}),ht=d([Ke,Dn]),ur=a(d([Ke,ze])),cr=a(d([ht,ze])),wn=n({type:i("date"),start_date:r(),reminder:ur}),Tn=n({type:i("daterange"),start_date:r(),end_date:r(),reminder:ur}),qn=n({type:i("datetime"),start_date:r(),start_time:r(),time_zone:a(r()),reminder:cr}),An=n({type:i("datetimerange"),start_date:r(),start_time:r(),end_date:r(),end_time:r(),time_zone:a(r()),reminder:cr}),lr=v("type",[wn,Tn,qn,An]);var Ze=n({id:r(),table:r()});var pr=d([r(),R(),g(),lr,O(r()),O(Ze)]);var mr=n({id:z,is_archived:g(),in_trash:g(),propertiesById:Q(r(),a(pr))});var Nn=r(),Un=B(["gray","lightgray","brown","yellow","orange","green","blue","purple","pink","red"]),gt=d([Un,r()]),bt=Ge({type:i("icon"),icon:Ge({name:Nn,color:a(gt)})});var fr=n({type:i("emoji"),emoji:r()}),yr=n({type:i("custom_emoji"),custom_emoji:n({id:r(),name:a(r()),url:a(r())})}),St=n({type:i("external"),external:n({url:r()})}),kt=n({type:i("file"),file:n({url:r(),expiry_time:a(r())})}),Oe=v("type",[bt,fr,yr,St,kt]),ge=v("type",[St,kt]),dr=v("type",[bt,fr,yr,St,kt]);var L=q(r());var It={start:r(),end:a(L),time_zone:a(L),reminder:a(d([ht,ze]))},vr=d([n({...It,start:A(r(),lt("T"))}),n({...It,time_zone:r()}),n({...It,reminder:a(d([Ke,ze]))})]);var hr=d([n({type:i("external"),name:r(),external:n({url:r()})}),n({type:i("file"),name:r(),file:n({url:r(),expiry_time:a(r())})})]);var Re=q(n({...Ze.entries,table:B(["notion_user","bot","organization_bot"]),spaceId:a(r())}));var gr=n({lat:R(),lon:R(),name:a(L),address:a(L),aws_place_id:a(L),google_place_id:a(L)});var br=n({id:r()});var _t=Q(r(),Se());var Je=d([n({id:r(),name:a(r()),color:a(r()),description:a(L)}),n({name:r(),id:a(r()),color:a(r()),description:a(L)})]);var Sr=d([n({object:a(i("user")),id:r()}),n({object:i("group"),id:r(),name:a(L)})]);var w={id:r()},xt=v("type",[n({...w,type:i("title"),title:O(_t)}),n({...w,type:i("rich_text"),rich_text:O(_t)}),n({...w,type:i("number"),number:q(R())}),n({...w,type:i("url"),url:L}),n({...w,type:i("email"),email:L}),n({...w,type:i("phone_number"),phone_number:L}),n({...w,type:i("checkbox"),checkbox:g()}),n({...w,type:i("select"),select:q(Je)}),n({...w,type:i("status"),status:q(Je)}),n({...w,type:i("multi_select"),multi_select:O(Je)}),n({...w,type:i("date"),date:q(vr)}),n({...w,type:i("people"),people:O(Sr)}),n({...w,type:i("relation"),has_more:a(g()),relation:O(br)}),n({...w,type:i("files"),files:O(hr)}),n({...w,type:i("place"),place:q(gr)}),n({...w,type:i("created_time"),created_time:L}),n({...w,type:i("last_edited_time"),last_edited_time:L}),n({...w,type:i("created_by"),created_by:Re}),n({...w,type:i("last_edited_by"),last_edited_by:Re}),n({...w,type:i("last_visited_time"),last_visited_time:L}),n({...w,type:i("unique_id"),unique_id:r()}),n({...w,type:i("button"),button:r()}),n({...w,type:i("formula"),formula:r()}),n({...w,type:i("location"),location:r()}),n({...w,type:i("rollup"),rollup:r()}),n({...w,type:i("verification"),verification:r()})]);var Be=Q(r(),xt),kr=Q(r(),q(xt));var oe=n({object:i("page"),id:z,parent:re,properties:kr,created_by:a(Re,null),last_edited_by:a(Re,null),last_visited_time:a(q(r()),null),created_time:a(q(r()),null),last_edited_time:a(q(r()),null),icon:a(q(Oe),null),cover:a(q(ge),null),url:a(q(r()),null),public_url:a(q(r()),null),is_archived:g(),in_trash:g()});var Ir=d([m({equals:g()}),m({does_not_equal:g()})]);var le=d([m({is_empty:i(!0)}),m({is_not_empty:i(!0)})]);var ke=d([r(),O(r())]);var _r=d([m({contains:ke}),m({contains_all:ke}),m({does_not_contain:ke}),le]);var xr=m({object:i("user"),id:A(r(),be(1),qe(2e3))}),Cr=d([m({contains:xr}),m({does_not_contain:xr}),m({is_empty:i(!0)}),m({is_not_empty:i(!0)})]);var Z=B(["start_date","end_date"]),Fn=B(["today","tomorrow","yesterday","one_week_ago","one_week_from_now","one_month_ago","one_month_from_now"]),He=d([Fn,r()]),Pr=d([m({target:a(Z),equals:He}),m({target:a(Z),before:He}),m({target:a(Z),after:He}),m({target:a(Z),on_or_before:He}),m({target:a(Z),on_or_after:He}),m({target:a(Z),this_week:m({})}),m({target:a(Z),past_week:m({})}),m({target:a(Z),past_month:m({})}),m({target:a(Z),past_year:m({})}),m({target:a(Z),next_week:m({})}),m({target:a(Z),next_month:m({})}),m({target:a(Z),next_year:m({})}),m({target:a(Z),is_empty:i(!0)}),m({target:a(Z),is_not_empty:i(!0)})]);var Er=d([m({equals:R()}),m({does_not_equal:R()}),m({greater_than:R()}),m({less_than:R()}),m({greater_than_or_equal_to:R()}),m({less_than_or_equal_to:R()}),le]);var Ye=d([m({equals:ke}),m({does_not_equal:ke}),le]);var Or=m({object:B(["user","group"]),id:A(r(),be(1))}),Rr=d([m({contains:Or}),m({does_not_contain:Or}),le]);var Br=A(z,pt(/^(?:[0-9a-f]{32}|[0-9a-f]{8}(?:-[0-9a-f]{4}){3}-[0-9a-f]{12})$/i),mt(e=>e.replaceAll("-","").toLowerCase().replace(/^(.{8})(.{4})(.{4})(.{4})(.{12})$/,"$1-$2-$3-$4-$5"))),et=d([m({contains:Br}),m({does_not_contain:Br}),m({is_empty:i(!0)}),m({is_not_empty:i(!0)})]);var jr=B(["To-do","In progress","Complete","Current","Future"]),Mr=d([jr,A(O(jr),be(1),qe(5))]),Dr=d([m({group_equals:Mr}),m({group_does_not_equal:Mr})]);var wr=d([Ye,Dr]);var je=d([m({equals:r()}),m({does_not_equal:r()}),m({contains:r()}),m({does_not_contain:r()}),m({starts_with:r()}),m({ends_with:r()}),le]);var Ct=d([m({propertyId:r(),relation:et}),m({propertyId:r(),created_by:Cr}),m({propertyId:r(),title:je}),m({propertyId:r(),rich_text:je}),m({propertyId:r(),url:je}),m({propertyId:r(),email:je}),m({propertyId:r(),phone_number:je}),m({propertyId:r(),number:Er}),m({propertyId:r(),checkbox:Ir}),m({propertyId:r(),select:Ye}),m({propertyId:r(),multi_select:_r}),m({propertyId:r(),status:wr}),m({propertyId:r(),date:Pr}),m({propertyId:r(),people:Rr})]);var Tr=d([Ct,m({and:O(Ct)})]);var qr=B(["ascending","descending"]);var Pt=10,Ar=m({propertyId:r(),direction:qr});var Nr=n({type:i("queryDataSource"),subscriptionId:r(),dataSourceId:K,limit:R(),filter:a(Tr),sorts:a(O(Ar))}),zn=r(),Ur=n({code:zn,message:r(),isRetryable:g()}),Fr=v("status",[n({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("success"),items:O(oe),hasMore:g()}),n({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("error"),error:Ur})]),zr=v("status",[n({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("success"),items:O(d([oe,mr])),hasMore:g()}),n({type:i("queryDataSourceResult"),subscriptionId:r(),status:i("error"),error:Ur})]);var Hn=r(),Ln=n({code:Hn,message:r(),isRetryable:g()}),Hr=n({type:i("openExternalUrl"),requestId:r(),url:r()}),Lr=v("status",[n({type:i("openExternalUrlResult"),requestId:r(),status:i("success")}),n({type:i("openExternalUrlResult"),requestId:r(),status:i("error"),error:Ln})]);var Me=n({object:i("page"),id:z,parent:re,properties:Be,created_time:a(r()),last_edited_time:a(r()),icon:a(Oe),cover:a(ge),url:a(r()),public_url:a(r()),is_archived:g(),in_trash:g()});var Vn=r(),Gr=n({code:Vn,message:r(),isRetryable:g()}),$r=v("status",[n({type:i("createPageResult"),requestId:r(),status:i("success"),page:oe}),n({type:i("createPageResult"),requestId:r(),status:i("error"),error:Gr})]),Qr=v("status",[n({type:i("createPageResult"),requestId:r(),status:i("success"),page:d([oe,Me])}),n({type:i("createPageResult"),requestId:r(),status:i("error"),error:Gr})]),Gn=v("type",[n({type:i("start")}),n({type:i("end")}),n({type:i("before"),blockId:fe}),n({type:i("after"),blockId:fe})]),fu=v("type",[$e,Qe]),Vr={type:i("createPage"),requestId:r(),properties:Be,icon:a(dr),cover:a(ge)},Wr=v("type",[n({...Vr,parent:$e,position:a(Gn)}),n({...Vr,parent:Qe,position:a(dt())})]);var $n=r(),Xr=n({code:$n,message:r(),isRetryable:g()}),Kr=n({type:i("getPage"),requestId:r(),pageId:z,dataSourceId:a(K)}),Zr=v("status",[n({type:i("getPageResult"),requestId:r(),status:i("success"),page:oe}),n({type:i("getPageResult"),requestId:r(),status:i("error"),error:Xr})]),Jr=v("status",[n({type:i("getPageResult"),requestId:r(),status:i("success"),page:d([oe,Me])}),n({type:i("getPageResult"),requestId:r(),status:i("error"),error:Xr})]);var Qn=B(["side_peek","center_peek"]),Wn=r(),Xn=n({code:Wn,message:r(),isRetryable:g()}),Yr=n({type:i("openPage"),requestId:r(),pageId:z,mode:Qn}),eo=v("status",[n({type:i("openPageResult"),requestId:r(),status:i("success"),pageId:z}),n({type:i("openPageResult"),requestId:r(),status:i("error"),error:Xn})]);var Kn=r(),to=n({code:Kn,message:r(),isRetryable:g()}),ro=v("status",[n({type:i("updatePageResult"),requestId:r(),status:i("success"),page:oe}),n({type:i("updatePageResult"),requestId:r(),status:i("error"),error:to})]),oo=v("status",[n({type:i("updatePageResult"),requestId:r(),status:i("success"),page:d([oe,Me])}),n({type:i("updatePageResult"),requestId:r(),status:i("error"),error:to})]),no=n({type:i("updatePage"),requestId:r(),pageId:z,dataSourceId:a(K),properties:a(Be),icon:a(Oe),cover:a(ge),archived:a(g())});var io=n({type:i("currentUserChanged"),currentUser:ce});var Zn=r(),Jn=n({code:Zn,message:r(),isRetryable:g()}),so=n({type:i("getUser"),requestId:r(),userId:We}),ao=v("status",[n({type:i("getUserResult"),requestId:r(),status:i("success"),user:ce}),n({type:i("getUserResult"),requestId:r(),status:i("error"),error:Jn})]);var uo=n({object:i("list"),results:O(ce),next_cursor:q(r()),has_more:g(),type:i("user"),user:Q(r(),Se())});var Yn=r(),ei=n({code:Yn,message:r(),isRetryable:g()}),co=n({type:i("listUsers"),requestId:r(),startCursor:a(r()),pageSize:a(R())}),lo=v("status",[n({type:i("listUsersResult"),requestId:r(),status:i("success"),list:uo}),n({type:i("listUsersResult"),requestId:r(),status:i("error"),error:ei})]);var po=n({type:i("invalidSandboxMessage"),requestId:a(r()),reason:r()});var mo=v("type",[Xe,sr,or,ir,nr,io,ar,ao,lo,eo,Lr,po]),fo=v("type",[...mo.options,Fr,Zr,$r,ro]),Yu=v("type",[...mo.options,zr,Jr,Qr,oo]);function yo(e){return{...e,dataSources:{bindings:Object.fromEntries(Object.entries(e.dataSources.bindings).map(([t,o])=>[t,{...o,collectionSchema:{...o.collectionSchema,propertiesById:{...o.collectionSchema?.propertiesById,...Zt}}}]))}}}function Y(e){throw new Error(`[custom-blocks-host] Unexpected value encountered: ${JSON.stringify(e)}`)}function tt(e){return{...e,properties:Object.fromEntries(Object.entries(e.properties).map(([t,o])=>{switch(o?.type){case"unique_id":case"button":case"formula":case"location":case"rollup":case"verification":return[t,null];case"title":case"rich_text":case"number":case"url":case"email":case"phone_number":case"checkbox":case"select":case"status":case"multi_select":case"date":case"people":case"relation":case"files":case"place":case"created_time":case"last_edited_time":case"created_by":case"last_edited_by":case"last_visited_time":case void 0:return[t,o];default:return Y(o)}}))}}function De(e){if(e?.type!=="icon")return e;let{name:t,color:o}=e.icon;return{type:"external",external:{url:`https://www.notion.so/icons/${t}_${o??"gray"}.svg`}}}function vo(e){return{...e,properties:Object.fromEntries(Object.values(e.properties).flatMap(t=>t?[[t.id,t]]:[])),icon:De(e.icon)??void 0,cover:e.cover??void 0,created_time:e.created_time??void 0,last_edited_time:e.last_edited_time??void 0,url:e.url??void 0,public_url:e.public_url??void 0}}function Ie(e){if(e==null||e==="")return;let t=new Date(e);if(Number.isFinite(t.getTime()))return{type:"datetime",start_date:t.toISOString().slice(0,10),start_time:t.toISOString().slice(11,16),time_zone:"UTC"}}var _e=class extends Error{};function Et(e){try{return ti(e)}catch(t){throw t instanceof RangeError?new _e(t.message):t}}function ti(e){let{start:t,end:o,time_zone:s,reminder:c}=e;if(!t.split("T")[0])throw new _e("Date values must include a date.");let l=t.includes("T")||s!=null,p=t.match(/([+-])(\d{2}):(\d{2})$/),h=p?(Number(p[2])*60+Number(p[3]))*(p[1]==="-"?-1:1):0,y=s?.match(/^UTC(?:([+-])(\d{1,2})(?::(\d{2}))?)?$/),x=y?(Number(y[2]??0)*60+Number(y[3]??0))*(y[1]==="-"?-1:1):h,k=b=>{if(!b.split("T")[0])throw new _e("Date values must include a date.");if(!b.includes("T"))return{date:b,time:"00:00"};let N=b.match(/^(\d{4}-\d{2}-\d{2})T(\d{2}:\d{2})(?::\d{2}(?:\.\d+)?)?$/);if(N)return{date:N[1],time:N[2]};if(!s||y){let U=new Date(new Date(b).getTime()+x*6e4).toISOString();return{date:U.slice(0,10),time:U.slice(11,16)}}let j=new Intl.DateTimeFormat("en-CA",{timeZone:s,year:"numeric",month:"2-digit",day:"2-digit",hour:"2-digit",minute:"2-digit",hourCycle:"h23"}).formatToParts(new Date(b)),H=U=>j.find(ee=>ee.type===U)?.value;return{date:`${H("year")}-${H("month")}-${H("day")}`,time:`${H("hour")}:${H("minute")}`}},T=k(t),W=o?k(o):void 0;if(!l){if(c&&!("time"in c)&&c.unit!=="none")throw new _e("Hour and minute reminders require a date with a time.");return W?{type:"daterange",start_date:T.date,end_date:W.date,reminder:c}:{type:"date",start_date:T.date,reminder:c}}let V=s??(h===0?"UTC":`UTC${h<0?"-":"+"}${Math.floor(Math.abs(h)/60)}${Math.abs(h)%60===0?"":`:${String(Math.abs(h)%60).padStart(2,"0")}`}`);return W?{type:"datetimerange",start_date:T.date,start_time:T.time,end_date:W.date,end_time:W.time,time_zone:V,reminder:c}:{type:"datetime",start_date:T.date,start_time:T.time,time_zone:V,reminder:c}}function go(e){switch(e.type){case"title":return ho(e.title);case"rich_text":return ho(e.rich_text);case"number":return e.number??void 0;case"checkbox":return e.checkbox;case"url":return e.url??"";case"email":return e.email??"";case"phone_number":return e.phone_number??"";case"select":return e.select?.name;case"status":return e.status?.name;case"multi_select":return e.multi_select.flatMap(t=>t.name??[]);case"date":return e.date?Et(e.date):void 0;case"people":return e.people.map(t=>t.object==="group"?{id:t.id,table:"space_permission_group",spaceId:t.id.split("|")[1]}:{id:t.id,table:"notion_user"});case"relation":return e.relation.map(t=>({id:t.id,table:"block"}));case"files":return e.files.map(t=>t.name).join(",");case"unique_id":return e.unique_id;case"button":return e.button;case"formula":return e.formula;case"location":return e.location;case"rollup":return e.rollup;case"verification":return e.verification;case"place":return"";case"created_time":return Ie(e.created_time);case"last_edited_time":return Ie(e.last_edited_time);case"last_visited_time":return Ie(e.last_visited_time);case"created_by":return e.created_by?[e.created_by]:void 0;case"last_edited_by":return e.last_edited_by?[e.last_edited_by]:void 0;default:return Y(e)}}function ho(e){return e.map(t=>{if(typeof t.plain_text=="string")return t.plain_text;let o=t.text;return o&&typeof o=="object"&&"content"in o&&typeof o.content=="string"?o.content:""}).join("")}function bo(e){let t={};for(let o of Object.values(e.properties))o&&(t[o.id]=go(o));return{id:e.id,is_archived:e.is_archived,in_trash:e.in_trash,propertiesById:{...t,created_time:Ie(e.created_time),last_edited_time:Ie(e.last_edited_time),created_by:e.created_by?[e.created_by]:void 0,last_edited_by:e.last_edited_by?[e.last_edited_by]:void 0}}}function So(e){return e.type==="queryDataSourceResult"?{...e,items:e.items.map(bo)}:{...e,page:vo(tt(e.page))}}function Io(e){return e.type==="queryDataSourceResult"?{...e,items:e.items.map(ko)}:{...e,page:ko(e.page)}}function ko(e){return{...tt(e),icon:De(e.icon)}}function xo(e){if(e.type==="queryDataSourceResult")return e.items.some(o=>o.icon?.type==="icon")?{...e,items:e.items.map(_o)}:e;let t=_o(e.page);return t===e.page?e:{...e,page:t}}function _o(e){let t=De(e.icon);return t===e.icon?e:{...e,icon:t}}function Co(e,t){return e.type==="init"&&e.status==="success"||e.type==="dataSourcesChanged"?t<5?yo(e):e:e.type!=="queryDataSourceResult"&&e.type!=="getPageResult"&&e.type!=="createPageResult"&&e.type!=="updatePageResult"||e.status==="error"?e:t<6?So(e):t<7?Io(e):t<9?xo(e):e}var Ot=n({theme:Ee,contrastMode:a(Pe),blockId:fe,parent:re,page:Ce,manifest:he,dataSources:n({bindings:ve}),currentUser:ce}),Po=v("status",[n({status:i("success"),initialState:Lt(Ot,["manifest"])}),n({status:i("error"),error:Fe})]);var rt=class{constructor(t){this.onUnsubscribe=t}onUnsubscribe;bySubscriptionId=new Map;subscribe(t){this.unsubscribe(t.subscriptionId);let o={_tag:"QuerySubscriptionToken"};return this.bySubscriptionId.set(t.subscriptionId,{message:t,token:o,isRefreshing:!0,shouldRefreshAgain:!1}),o}isCurrent(t,o){return this.bySubscriptionId.get(t)?.token===o}unsubscribe(t){this.bySubscriptionId.delete(t)&&this.onUnsubscribe(t)}refresh(t){let o=[],s=!1;for(let c of this.bySubscriptionId.values())if(c.message.dataSourceId===t){if(s=!0,c.isRefreshing){c.shouldRefreshAgain=!0;continue}c.isRefreshing=!0,o.push({message:c.message,token:c.token})}return s?o:void 0}finish(t,o){let s=this.bySubscriptionId.get(t);if(s?.token===o&&(s.isRefreshing=!1,!!s.shouldRefreshAgain))return s.shouldRefreshAgain=!1,s.isRefreshing=!0,{message:s.message,token:s.token}}unsubscribeAll(){for(let t of this.bySubscriptionId.keys())this.unsubscribe(t)}};function Eo(e,t){if(e===void 0)return;let o="and"in e?e.and:[e];for(let s of o){let c=ii(s,t);if(c!==void 0)return c}}function ii(e,t){if(!Object.hasOwn(t.propertiesById,e.propertyId))return{code:"invalid_data_source_query_filter",message:`Data source query filter property ID "${e.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let o=t.propertiesById[e.propertyId],s=Object.keys(e).find(h=>h!=="propertyId");if(s!==o.type)return{code:"invalid_data_source_query_filter",message:`Data source query filter branch "${s}" does not match property type "${o.type}".`,isRetryable:!1};if("status"in e&&o.type==="status"){let h=e.status;if("group_equals"in h||"group_does_not_equal"in h){let y="group_equals"in h?h.group_equals:h.group_does_not_equal,k=(Array.isArray(y)?y:[y]).find(T=>!o.groups.some(W=>W.name===T));return k===void 0?void 0:{code:"invalid_data_source_query_filter",message:`Unknown status group "${k}".`,isRetryable:!1}}}if("relation"in e&&!Ht(et,e.relation))return{code:"invalid_data_source_query_filter",message:"Relation filters require a page ID.",isRetryable:!1};let c=si(e);if(c===void 0||o.type!==c.propertyType)return;let l=new Set(o.options.map(h=>h.name)),p=ai(c.operator).find(h=>!l.has(h));if(p!==void 0)return{code:"invalid_data_source_query_filter",message:`Data source query filter option "${p}" is not defined for property "${e.propertyId}".`,isRetryable:!1}}function si(e){if("select"in e)return{propertyType:"select",operator:e.select};if("multi_select"in e)return{propertyType:"multi_select",operator:e.multi_select};if("status"in e){let t=e.status;return"group_equals"in t||"group_does_not_equal"in t?void 0:{propertyType:"status",operator:t}}}function ai(e){let t;if("equals"in e)t=e.equals;else if("does_not_equal"in e)t=e.does_not_equal;else if("contains"in e)t=e.contains;else if("contains_all"in e)t=e.contains_all;else if("does_not_contain"in e)t=e.does_not_contain;else return"is_empty"in e||"is_not_empty"in e?[]:Y(e);return Array.isArray(t)?t:[t]}var ui=new Set(Xt);function Oo(e,t){if(e===void 0)return;if(e.length>Pt)return{code:"invalid_data_source_query_sort",message:`Data source query sorts may contain at most ${Pt} entries.`,isRetryable:!1};let o=new Set;for(let s of e){if(o.has(s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sorts cannot contain duplicate property ID "${s.propertyId}".`,isRetryable:!1};if(o.add(s.propertyId),!Object.hasOwn(t.propertiesById,s.propertyId))return{code:"invalid_data_source_query_sort",message:`Data source query sort property ID "${s.propertyId}" is not defined in the bound data source schema.`,isRetryable:!1};let c=t.propertiesById[s.propertyId];if(!ui.has(c.type))return{code:"invalid_data_source_query_sort",message:`Data source query sorts do not yet support property type "${c.type}".`,isRetryable:!1}}}function Ro(){return{code:"initial_state_timeout",message:"Host did not prepare initial state before the timeout.",isRetryable:!0}}function Rt(e){let{currentBridgeProtocolVersion:t}=e;return{code:"invalid_protocol_version",message:`Sandbox reported an invalid bridge protocol version: ${t}`,isRetryable:!1}}function Bo(){return{code:"no_connect",message:"Sandbox did not send a connect message.",isRetryable:!0}}function jo(){return{code:"no_init_result",message:"Sandbox did not acknowledge initialization.",isRetryable:!0}}function ot(){return{code:"unknown_error",message:"Unexpected error while initializing custom block.",isRetryable:!1}}function Bt(e){let{currentBridgeProtocolVersion:t,minBridgeProtocolVersion:o}=e;return{code:"unsupported_protocol_version",message:`Sandbox bridge protocol version ${t} is not supported. Minimum supported version is ${o}.`,isRetryable:!1}}function jt(e){return Number.isFinite(e)&&Number.isInteger(e)&&e>=1}var ci=5e3,li=5e3,pi=5e3;function Mo(e){let{manifestSource:t,prepareInit:o,sendInitMessage:s,warn:c,flushPendingHostStateChanges:l,minBridgeProtocolVersion:p,noConnectTimeoutMs:h=ci,initialStateTimeoutMs:y=li,noInitResultTimeoutMs:x=pi,stopHostWithFailure:k,onInitResult:T,onInitSent:W,onConnectionFailure:V}=e,b="waitingForConnect",N,j,H,U,ee=!1,ye=!1;function te(){N!==void 0&&(window.clearTimeout(N),N=void 0)}function F(){j!==void 0&&(window.clearTimeout(j),j=void 0)}function G(){H!==void 0&&(window.clearTimeout(H),H=void 0)}function X(I){let{initializationId:P,error:_,phase:ae,source:it}=I;switch(b){case"waitingForConnect":case"preparingInit":break;case"waitingForInitResult":case"initialized":case"failed":case"stopped":return;default:return Y(b)}b="failed",U=P,te(),F(),s({type:"init",initializationId:P,status:"error",error:_}),V({..._,phase:ae,source:it})}async function se(I){if(b==="waitingForConnect"){b="preparingInit",U=I.initializationId,te(),j=window.setTimeout(()=>{if(b!=="preparingInit")return;let P=Ro();c({...P,initializationId:I.initializationId}),X({initializationId:I.initializationId,error:P,phase:"init",source:"host"})},y);try{let P=await o(I);if(b!=="preparingInit")return;if(F(),P.status==="error"){X({initializationId:I.initializationId,error:P.error,phase:"init",source:"host"});return}b="waitingForInitResult";let _={type:"init",initializationId:I.initializationId,status:"success",theme:P.initialState.theme,contrastMode:P.initialState.contrastMode??tr,blockId:P.initialState.blockId,parent:P.initialState.parent,page:P.initialState.page,currentUser:P.initialState.currentUser,manifest:P.initialState.manifest,dataSources:P.initialState.dataSources};if(s(_),b!=="waitingForInitResult"||(W(),b!=="waitingForInitResult"))return;H=window.setTimeout(()=>{if(b!=="waitingForInitResult")return;b="failed";let ae=jo();V({...ae,phase:"initResult",source:"host"}),c({...ae,initializationId:I.initializationId})},x)}catch(P){if(b!=="preparingInit")return;c({message:"Failed to prepare custom block initialization",error:P}),X({initializationId:I.initializationId,error:ot(),phase:"init",source:"host"})}}}function J(I){if(b!=="stopped"&&b==="waitingForConnect"){if(!jt(I.bridgeProtocolVersion)){let P=Rt({currentBridgeProtocolVersion:I.bridgeProtocolVersion});X({initializationId:I.initializationId,error:P,phase:"connect",source:"host"});return}if(I.bridgeProtocolVersion<p){let P=Bt({currentBridgeProtocolVersion:I.bridgeProtocolVersion,minBridgeProtocolVersion:p});X({initializationId:I.initializationId,error:P,phase:"connect",source:"host"});return}if(I.status==="error"&&(t==="sandbox"||I.error.code!=="manifest_invalid")){X({initializationId:I.initializationId,error:I.error,phase:"connect",source:"sandbox"});return}ye=!0,se(I)}}function C(I){if(b==="stopped"||b!=="waitingForConnect")return"handled";let{initializationId:P,bridgeProtocolVersion:_}=I;if(P===void 0)return"nack";let ae=I.error;return _!==void 0&&(jt(_)?_<p&&(ae=Bt({currentBridgeProtocolVersion:_,minBridgeProtocolVersion:p})):ae=Rt({currentBridgeProtocolVersion:_})),X({initializationId:P,error:ae,phase:"connect",source:"host"}),"handled"}function ne(I){let{initializationId:P,error:_}=I;b!=="waitingForInitResult"||P===void 0||P!==U||(te(),G(),b="failed",c(_),V({..._,phase:"initResult",source:"host"}))}function Le(){if(b!=="stopped"){if(ee){k({phase:"runtime",source:"host",code:"iframe_reloaded",message:"The iframe reloaded. Create a new host and iframe to reconnect.",isRetryable:!0});return}ee=!0,te(),b==="waitingForConnect"&&(N=window.setTimeout(()=>{if(b!=="waitingForConnect")return;b="failed";let I=Bo();c(I),V({...I,phase:"connect",source:"host"})},h))}}function we(I){if(b!=="waitingForInitResult"||I.initializationId!==U){c({message:"Ignored stale or unexpected initResult",payload:I});return}G(),b=I.status==="success"?"initialized":"failed",I.status==="success"?l():V({...I.error,phase:"initResult",source:"sandbox"}),T(I)}function de(){b="stopped",te(),F(),G()}return{get status(){return b},get hasConnectedSandbox(){return ye},handleConnect:J,handleInitResult:we,handleInvalidConnect:C,handleInvalidInitResult:ne,onIframeLoad:Le,stop:de}}function Mt(){return{code:"context_unavailable",message:"Host page context is unavailable.",isRetryable:!0}}function Dt(){return{code:"invalid_local_preview_url",message:"Local custom blocks require an HTTP(S) URL on localhost, a .localhost subdomain, or 127.0.0.1, without credentials and on a different origin from the host.",isRetryable:!1}}function Do(){return{code:"invalid_property_binding",message:"A mapped data source property is missing or incompatible.",isRetryable:!1}}function wo(){return{code:"missing_data_source_binding",message:"A required data source is not mapped.",isRetryable:!1}}function To(){return{code:"missing_property_binding",message:"A required data source property is not mapped.",isRetryable:!1}}function qo(e){return(e.protocol==="http:"||e.protocol==="https:")&&(e.hostname==="localhost"||e.hostname==="127.0.0.1"||e.hostname.endsWith(".localhost"))&&e.username===""&&e.password===""}function nt({url:e,hostOrigin:t}){return typeof t=="string"&&t!==""&&e.origin!==t&&qo(e)}async function Ao(e){return e.manifestSource==="host"?e.hostManifest:e.connectManifest!==void 0?{status:"success",manifest:e.connectManifest}:{status:"error",error:{code:"manifest_unavailable",message:"The sandbox did not provide a manifest in connect.",isRetryable:!1}}}var No=v("status",[n({status:i("success"),manifest:he}),n({status:i("error"),error:Fe})]);function Uo(e){switch(e.type){case"connect":case"init":case"initResult":return!0;default:return!1}}var Fo=n({type:i("resize"),height:A(R(),Te(),Ae(0))});var zo=n({type:i("unsubscribeDataSourceQuery"),subscriptionId:r()});var Ho=n({code:r(),message:r(),isRetryable:g()});var Lo={type:i("connect"),initializationId:r(),bridgeProtocolVersion:R(),sdkVersion:r()},Vo=v("status",[n({status:i("success"),manifest:a(he),...Lo}),n({status:i("error"),error:Ho,...Lo})]);var mi=r(),fi=n({code:mi,message:r(),isRetryable:g()}),Go=v("status",[n({type:i("initResult"),initializationId:r(),status:i("success"),initialHeight:a(A(R(),Te(),Ae(0)))}),n({type:i("initResult"),initializationId:r(),status:i("error"),error:fi})]);var $o=n({type:i("invalidHostMessage"),requestId:a(r()),reason:r()});var Qo=v("type",[Vo,Go,Nr,zo,Wr,Kr,so,co,Yr,Hr,no,Fo,$o]);function Wo(e){return ie(Qo,e)}function Xo(){return{code:"invalid_connect_payload",message:"Sandbox sent an invalid connect message.",isRetryable:!1}}function Ko(){return{code:"invalid_init_result_payload",message:"Sandbox sent an invalid initialization result.",isRetryable:!1}}function Zo(e){if(typeof e=="object"&&e!==null&&"type"in e&&typeof e.type=="string")return e.type}var yi=n({requestId:r()});function Jo(e){let t=ie(yi,e);return t.success?t.output.requestId:void 0}function Yo(e){let t=Zo(e);if(t==="invalidHostMessage"||t==="invalidSandboxMessage")return{incomingType:t};let o=Jo(e);return{incomingType:t,nack:{type:"invalidSandboxMessage",...o!==void 0?{requestId:o}:{},reason:di(t)}}}function di(e){return e!==void 0?`Unsupported sandbox message of type "${e}"`:"Unsupported sandbox message (no `type` field or non-object payload)"}var vi=n({type:B(["updatePage","createPage"]),requestId:r(),icon:n({type:i("icon"),icon:n({color:Se()})})});function en(e){let t=ie(vi,e);if(!t.success)return;let o=t.output.icon.icon.color;if(!(o===void 0||ie(gt,o).success))return{type:t.output.type==="createPage"?"createPageResult":"updatePageResult",requestId:t.output.requestId,status:"error",error:{code:"invalid_icon_color",message:"Use a supported Notion icon color.",isRetryable:!1}}}var tn=n({initializationId:r()}),hi=n({bridgeProtocolVersion:d([R(),yt()])});function rn(e){let{iframe:t,sandboxOrigin:o,getInitStatus:s,emit:c,sendNack:l,sendPageMutationError:p,onInvalidConnect:h,onInvalidInitResult:y,onConnect:x,onInitResult:k,onQueryDataSource:T,onUnsubscribeDataSourceQuery:W,onCreatePage:V,onGetPage:b,onOpenPage:N,onOpenExternalUrl:j,onGetUser:H,onListUsers:U,onUpdatePage:ee,onResize:ye}=e;function te(F,G){let X=en(F);if(X!==void 0&&s()==="initialized"){p(X);return}c("warn",{message:"Ignored unsupported sandbox message",payload:wt(F),issues:G});let se=Yo(F);if(se.incomingType==="connect"){let J=ie(tn,F),C=ie(hi,F);if(h({initializationId:J.success?J.output.initializationId:void 0,error:Xo(),bridgeProtocolVersion:C.success?C.output.bridgeProtocolVersion:void 0})==="handled")return}if(se.incomingType==="initResult"){let J=ie(tn,F);y({initializationId:J.success?J.output.initializationId:void 0,error:Ko()})}se.nack!==void 0&&s()!=="stopped"&&l(se.nack)}return function(G){let X=G.source===t.contentWindow,se=G.origin===o;if(!X||!se)return;let J=Wo(G.data);if(!J.success){te(G.data,J.issues);return}let C=J.output;if(!Uo(C)&&s()!=="initialized"){c("warn",{message:`Ignored ${C.type} before initialization completed`,payload:wt(C)});return}switch(c("in",wt(C)),C.type){case"connect":x(C);return;case"initResult":k(C);return;case"queryDataSource":T(C);return;case"unsubscribeDataSourceQuery":W(C);return;case"createPage":V(C);return;case"openPage":N(C);return;case"openExternalUrl":j(C);return;case"getPage":b(C);return;case"getUser":H(C);return;case"listUsers":U(C);return;case"updatePage":ee(C);return;case"resize":ye(C);return;case"invalidHostMessage":return;default:Y(C)}}}function wt(e){return typeof e=="object"&&e!==null&&"type"in e&&e.type==="openExternalUrl"?{type:"openExternalUrl",..."requestId"in e?{requestId:e.requestId}:{}}:e}function on(e){if(e.length>2048||!URL.canParse(e))return;let t=new URL(e);if(!(t.protocol!=="http:"&&t.protocol!=="https:"||t.username!==""||t.password!==""||t.href.length>2048))return t.href}var sn=5;function bi(e){let{iframe:t,prepareInitialState:o,handlers:s,onStatusChange:c,onLog:l,onQueryUnsubscribed:p,minBridgeProtocolVersion:h,noConnectTimeoutMs:y,initialStateTimeoutMs:x,noInitResultTimeoutMs:k}=e,T=Si(e.sandboxUrl,e.manifestSource),W=T.origin,V=Math.max(h??3,3),b=new AbortController,N,j={},H=!1,U=new AbortController,ee,ye,te=9,F=new rt(u=>{p?.(u)});function G(u,S){l?.(u,S)}function X(u){let S=_.status;switch(S){case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"initialized":case"failed":break;case"stopped":return;default:return Y(S)}let E=Co(u,te);G("out",E),t.contentWindow?.postMessage(E,W)}function se(u){X(ue(Xe,u))}function J(u){X(u)}function C(u){let S=_.status;switch(S){case"initialized":X(ue(fo,u));return;case"waitingForConnect":case"preparingInit":case"waitingForInitResult":case"failed":case"stopped":return;default:Y(S)}}async function ne(u,S){try{let E=S===void 0?Ii(u.type):await S(u);C({...E,type:`${u.type}Result`,requestId:u.requestId})}catch(E){if(_.status!=="initialized")return;G("warn",E),C({type:`${u.type}Result`,requestId:u.requestId,status:"error",error:{code:"unknown_error",message:`The host could not complete ${u.type}.`,isRetryable:!1}})}}function Le(u){let S=u.response.status==="error"?{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"error",error:u.response.error}:{type:"queryDataSourceResult",subscriptionId:u.subscriptionId,status:"success",items:u.response.items,hasMore:u.response.hasMore};C(S)}async function we(u,S=F.subscribe(u)){try{let E=ki(ye,u.dataSourceId),pe=_i(u,E);if(pe!==void 0){F.isCurrent(u.subscriptionId,S)&&(F.unsubscribe(u.subscriptionId),Le({subscriptionId:u.subscriptionId,response:{status:"error",error:pe}}));return}let at=await s.queryDataSource(u);if(!F.isCurrent(u.subscriptionId,S))return;at.status==="error"&&!at.error.isRetryable&&F.unsubscribe(u.subscriptionId),Le({subscriptionId:u.subscriptionId,response:at})}finally{let E=F.finish(u.subscriptionId,S);E!==void 0&&we(E.message,E.token)}}function de(u){_.status==="stopped"||_.status==="failed"||(Object.assign(j,u),P())}async function I(u){if(b.signal.aborted)return;let S=s.openExternalUrl;if(S===void 0){await ne(u,void 0);return}if(N===u.requestId)return;if(N!==void 0){let pe={type:"openExternalUrlResult",requestId:u.requestId,status:"error",error:{code:"pending_navigation",message:"Another external navigation request is pending.",isRetryable:!0}};C(pe);return}let E=on(u.url);if(E===void 0){let pe={type:"openExternalUrlResult",requestId:u.requestId,status:"error",error:{code:"invalid_url",message:"Only valid HTTP or HTTPS URLs without credentials, up to 2,048 characters, can be opened.",isRetryable:!1}};C(pe);return}N=u.requestId;try{await ne(u,()=>S({...u,url:E},{signal:b.signal}))}finally{N===u.requestId&&(N=void 0)}}function P(){if(_.status!=="initialized")return;let u=j;j={},u.theme!==void 0&&C({type:"themeChanged",theme:u.theme}),u.contrastMode!==void 0&&C({type:"contrastModeChanged",contrastMode:u.contrastMode}),u.parent!==void 0&&C({type:"parentChanged",parent:u.parent}),u.page!==void 0&&C({type:"pageChanged",page:u.page}),u.dataSources!==void 0&&C({type:"dataSourcesChanged",dataSources:u.dataSources}),u.currentUser!==void 0&&C({type:"currentUserChanged",currentUser:u.currentUser})}let _=Mo({manifestSource:e.manifestSource,async prepareInit(u){let S=u.status==="success"?u.manifest:void 0;te=u.bridgeProtocolVersion,c({status:"preparingInit",localManifest:nt({url:T,hostOrigin:window.location.origin})?S:void 0,bridgeProtocolVersion:u.bridgeProtocolVersion,sdkVersion:u.sdkVersion});let E=await(cn??qt(S));return _.status!=="preparingInit"?E:ae(E)},sendInitMessage:se,onInitSent:()=>c({status:"waitingForInitResult"}),warn:u=>G("warn",u),flushPendingHostStateChanges:P,minBridgeProtocolVersion:V,noConnectTimeoutMs:y,initialStateTimeoutMs:x,noInitResultTimeoutMs:k,stopHostWithFailure:Nt,onInitResult(u){u.status==="success"&&ee!==void 0&&c({status:"initialized",resolvedManifest:ee,initialHeight:u.initialHeight})},onConnectionFailure:u=>{U.abort(),c({status:"failed",error:u})}});function ae(u){if(u.status==="error")return u;let S=ue(Ot,{...u.initialState,...j});if(ee=S.manifest,j={},te<sn&&S.page.type==="unavailable")return{status:"error",error:Mt()};let E=an(S.manifest,S.dataSources);return E!==void 0?{status:"error",error:E}:(ye=S.dataSources,H=!0,{status:"success",initialState:S})}let it=ln().catch(Tt),cn=e.manifestSource==="host"?qt(void 0).catch(Tt):void 0;async function ln(){U.signal.throwIfAborted();let u=await e.getPersistedManifest({signal:U.signal});return U.signal.throwIfAborted(),ue(No,u)}function Tt(u){return U.signal.aborted||G("warn",{message:"Failed to prepare custom block initialization",error:u}),{status:"error",error:ot()}}async function qt(u){U.signal.throwIfAborted();let S=await Ao({manifestSource:e.manifestSource,hostManifest:it,connectManifest:u});if(U.signal.throwIfAborted(),S.status==="error")return S;let E=ue(Po,await o({manifest:S.manifest,signal:U.signal}));return E.status==="error"?E:{status:"success",initialState:{...E.initialState,manifest:S.manifest}}}let At=rn({iframe:t,sandboxOrigin:W,getInitStatus:()=>_.status,emit:G,sendNack:J,sendPageMutationError:X,onInvalidConnect:_.handleInvalidConnect,onInvalidInitResult:_.handleInvalidInitResult,onConnect:_.handleConnect,onInitResult:_.handleInitResult,onQueryDataSource:we,onUnsubscribeDataSourceQuery:u=>F.unsubscribe(u.subscriptionId),onOpenExternalUrl:I,onCreatePage:u=>ne(u,s.createPage),onGetPage:u=>ne(u,s.getPage),onOpenPage:u=>ne(u,s.openPage),onGetUser:u=>ne(u,s.getUser),onListUsers:u=>ne(u,s.listUsers),onUpdatePage:u=>ne(u,s.updatePage),onResize:u=>s.resize?.(u)});window.addEventListener("message",At),t.addEventListener("load",_.onIframeLoad);function st(){b.abort(),U.abort(),window.removeEventListener("message",At),t.removeEventListener("load",_.onIframeLoad),_.stop(),F.unsubscribeAll()}function pn(){let u=_.status;st(),u!=="stopped"&&u!=="failed"&&c({status:"stopped"})}function Nt(u){if(_.status!=="stopped"){if(_.status==="failed"){st();return}st(),G("warn",u),c({status:"failed",error:u})}}return c({status:"waitingForConnect"}),{stop:pn,setTheme(u){de({theme:u})},setContrastMode(u){de({contrastMode:u})},setParent(u){de({parent:u})},setPage(u){if(u.type==="unavailable"&&te<sn&&(_.status==="preparingInit"&&H||_.status==="waitingForInitResult"||_.status==="initialized")){Nt({...Mt(),phase:"runtime",source:"host"});return}de({page:u})},setCurrentUser(u){de({currentUser:u})},setDataSources(u){let S={bindings:ue(ve,u.bindings)},E=_.hasConnectedSandbox&&ee!==void 0?an(ee,S):void 0;return E!==void 0?(G("warn",{message:"Ignored invalid data source bindings update",payload:S}),{status:"error",error:E}):(ye=S,de({dataSources:S}),{status:"success"})},refreshQuery({dataSourceId:u}){if(_.status!=="initialized")return;let S=ue(K,u),E=F.refresh(S);if(E===void 0){G("warn",`No active query exists for data source "${u}"`);return}for(let pe of E)we(pe.message,pe.token)}}}function Si(e,t){let o;try{o=new URL(e)}catch(s){throw t==="host"?s:new Ue(Dt())}if(t==="sandbox"&&!nt({url:o,hostOrigin:window.location.origin}))throw new Ue(Dt());return o}function ki(e,t){return Object.values(e?.bindings??{}).find(o=>o.collectionPointer?.id===t)?.collectionSchema}function an(e,t){for(let[o,s]of Object.entries(e.dataSources)){let c=t.bindings[o];if(c?.inaccessible===!0)continue;let l=er({manifestDataSource:s,collectionSchema:c?.collectionSchema,propertyIdsByKey:c?.propertyIdsByKey});if(c?.collectionPointer===void 0||l.status==="missing_schema")return wo();for(let p of l.properties){if(p.status==="missing")return To();if(p.status!=="mapped")return Do()}}}function Ii(e){return{status:"error",error:{code:"unsupported_operation",message:`The host does not support ${e}.`,isRetryable:!1}}}function _i(e,t){return t===void 0?e.filter===void 0&&(e.sorts?.length??0)===0?void 0:{code:"data_source_schema_unavailable",message:"You cannot query this data source with filters or sorts because its schema is unavailable.",isRetryable:!1}:Eo(e.filter,t)??Oo(e.sorts,t)}function xi(e){let{manifestProperties:t,propertySchemasById:o}=e,s=[];for(let[c,l]of Object.entries(t)){let p=Ci({propertyKey:c,manifestProperty:l,propertySchemasById:o});p!==void 0&&s.push([c,p])}return Object.fromEntries(s)}function Ci(e){let{propertyKey:t,manifestProperty:o,propertySchemasById:s}=e,c=un(o.name),l=Object.entries(s).filter(([p,h])=>h.type===o.type&&(p===t||un(h.name)===c));return l.length===1?l[0][0]:void 0}function un(e){return e.trim().toLowerCase()}function Pi(e){return ue(z,e)}export{_e as InvalidNotionDateError,bi as createCustomBlockHost,xi as getAutoBoundPropertyIdsByKey,nt as isAllowedLocalPreviewUrl,Et as toNotionDateValue,Pi as toNotionPageId};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeHostToSandboxMessage.d.ts","sourceRoot":"","sources":["../../src/compatibility/normalizeHostToSandboxMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,oBAAoB,EACpB,iDAAiD,EACjD,MAAM,4DAA4D,CAAA;
|
|
1
|
+
{"version":3,"file":"normalizeHostToSandboxMessage.d.ts","sourceRoot":"","sources":["../../src/compatibility/normalizeHostToSandboxMessage.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,oBAAoB,EACpB,iDAAiD,EACjD,MAAM,4DAA4D,CAAA;AAWnE;;;;GAIG;AACH,wBAAgB,6BAA6B,CAC5C,OAAO,EAAE,oBAAoB,EAC7B,qBAAqB,EAAE,MAAM,GAC3B,iDAAiD,CAoCnD"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
|
-
import { TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION, UNIFIED_PAGE_PROTOCOL_VERSION, } from "../protocol/utils/protocolVersion.js";
|
|
1
|
+
import { NATIVE_ICON_PROTOCOL_VERSION, TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION, UNIFIED_PAGE_PROTOCOL_VERSION, } from "../protocol/utils/protocolVersion.js";
|
|
2
2
|
import { addMetadataReadSchemasForProtocol3To4 } from "./protocol3To4/addMetadataReadSchemasForProtocol3To4.js";
|
|
3
3
|
import { normalizePageResultsForProtocol3To5 } from "./protocol3To5/normalizePageResultsForProtocol3To5.js";
|
|
4
4
|
import { normalizePageResultsForProtocol6 } from "./protocol6/normalizePageResultsForProtocol6.js";
|
|
5
|
+
import { normalizePageResultsForProtocol7To8 } from "./protocol7To8/normalizePageResultsForProtocol7To8.js";
|
|
5
6
|
/**
|
|
6
7
|
* Encodes current host messages for the sandbox's declared protocol. Handlers use
|
|
7
8
|
* current shapes. Each target adapter starts from that shape to avoid data loss.
|
|
@@ -35,5 +36,8 @@ export function normalizeHostToSandboxMessage(message, bridgeProtocolVersion) {
|
|
|
35
36
|
if (bridgeProtocolVersion < TEXT_FALLBACK_PROPERTY_PROTOCOL_VERSION) {
|
|
36
37
|
return normalizePageResultsForProtocol6(message);
|
|
37
38
|
}
|
|
39
|
+
if (bridgeProtocolVersion < NATIVE_ICON_PROTOCOL_VERSION) {
|
|
40
|
+
return normalizePageResultsForProtocol7To8(message);
|
|
41
|
+
}
|
|
38
42
|
return message;
|
|
39
43
|
}
|
|
@@ -797,6 +797,46 @@ export declare function normalizeSandboxToHostMessage(payload: unknown): v.SafeP
|
|
|
797
797
|
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
798
798
|
readonly verification: v.StringSchema<undefined>;
|
|
799
799
|
}, undefined>], undefined>, undefined>;
|
|
800
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
801
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
802
|
+
readonly icon: v.LooseObjectSchema<{
|
|
803
|
+
readonly name: v.StringSchema<undefined>;
|
|
804
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../protocol/index.js").NotionIconColor>, undefined>;
|
|
805
|
+
}, undefined>;
|
|
806
|
+
}, undefined>, v.ObjectSchema<{
|
|
807
|
+
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
808
|
+
readonly emoji: v.StringSchema<undefined>;
|
|
809
|
+
}, undefined>, v.ObjectSchema<{
|
|
810
|
+
readonly type: v.LiteralSchema<"custom_emoji", undefined>;
|
|
811
|
+
readonly custom_emoji: v.ObjectSchema<{
|
|
812
|
+
readonly id: v.StringSchema<undefined>;
|
|
813
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
814
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
815
|
+
}, undefined>;
|
|
816
|
+
}, undefined>, v.ObjectSchema<{
|
|
817
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
818
|
+
readonly external: v.ObjectSchema<{
|
|
819
|
+
readonly url: v.StringSchema<undefined>;
|
|
820
|
+
}, undefined>;
|
|
821
|
+
}, undefined>, v.ObjectSchema<{
|
|
822
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
823
|
+
readonly file: v.ObjectSchema<{
|
|
824
|
+
readonly url: v.StringSchema<undefined>;
|
|
825
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
826
|
+
}, undefined>;
|
|
827
|
+
}, undefined>], undefined>, undefined>;
|
|
828
|
+
readonly cover: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
829
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
830
|
+
readonly external: v.ObjectSchema<{
|
|
831
|
+
readonly url: v.StringSchema<undefined>;
|
|
832
|
+
}, undefined>;
|
|
833
|
+
}, undefined>, v.ObjectSchema<{
|
|
834
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
835
|
+
readonly file: v.ObjectSchema<{
|
|
836
|
+
readonly url: v.StringSchema<undefined>;
|
|
837
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
838
|
+
}, undefined>;
|
|
839
|
+
}, undefined>], undefined>, undefined>;
|
|
800
840
|
readonly parent: v.ObjectSchema<{
|
|
801
841
|
readonly type: v.LiteralSchema<"page_id", undefined>;
|
|
802
842
|
readonly page_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionPageId">]>;
|
|
@@ -1030,6 +1070,46 @@ export declare function normalizeSandboxToHostMessage(payload: unknown): v.SafeP
|
|
|
1030
1070
|
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
1031
1071
|
readonly verification: v.StringSchema<undefined>;
|
|
1032
1072
|
}, undefined>], undefined>, undefined>;
|
|
1073
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
1074
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
1075
|
+
readonly icon: v.LooseObjectSchema<{
|
|
1076
|
+
readonly name: v.StringSchema<undefined>;
|
|
1077
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../protocol/index.js").NotionIconColor>, undefined>;
|
|
1078
|
+
}, undefined>;
|
|
1079
|
+
}, undefined>, v.ObjectSchema<{
|
|
1080
|
+
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
1081
|
+
readonly emoji: v.StringSchema<undefined>;
|
|
1082
|
+
}, undefined>, v.ObjectSchema<{
|
|
1083
|
+
readonly type: v.LiteralSchema<"custom_emoji", undefined>;
|
|
1084
|
+
readonly custom_emoji: v.ObjectSchema<{
|
|
1085
|
+
readonly id: v.StringSchema<undefined>;
|
|
1086
|
+
readonly name: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1087
|
+
readonly url: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1088
|
+
}, undefined>;
|
|
1089
|
+
}, undefined>, v.ObjectSchema<{
|
|
1090
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
1091
|
+
readonly external: v.ObjectSchema<{
|
|
1092
|
+
readonly url: v.StringSchema<undefined>;
|
|
1093
|
+
}, undefined>;
|
|
1094
|
+
}, undefined>, v.ObjectSchema<{
|
|
1095
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
1096
|
+
readonly file: v.ObjectSchema<{
|
|
1097
|
+
readonly url: v.StringSchema<undefined>;
|
|
1098
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1099
|
+
}, undefined>;
|
|
1100
|
+
}, undefined>], undefined>, undefined>;
|
|
1101
|
+
readonly cover: v.OptionalSchema<v.VariantSchema<"type", [v.ObjectSchema<{
|
|
1102
|
+
readonly type: v.LiteralSchema<"external", undefined>;
|
|
1103
|
+
readonly external: v.ObjectSchema<{
|
|
1104
|
+
readonly url: v.StringSchema<undefined>;
|
|
1105
|
+
}, undefined>;
|
|
1106
|
+
}, undefined>, v.ObjectSchema<{
|
|
1107
|
+
readonly type: v.LiteralSchema<"file", undefined>;
|
|
1108
|
+
readonly file: v.ObjectSchema<{
|
|
1109
|
+
readonly url: v.StringSchema<undefined>;
|
|
1110
|
+
readonly expiry_time: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1111
|
+
}, undefined>;
|
|
1112
|
+
}, undefined>], undefined>, undefined>;
|
|
1033
1113
|
readonly parent: v.ObjectSchema<{
|
|
1034
1114
|
readonly type: v.LiteralSchema<"data_source_id", undefined>;
|
|
1035
1115
|
readonly data_source_id: v.SchemaWithPipe<readonly [v.StringSchema<undefined>, v.BrandAction<string, "NotionDataSourceId">]>;
|
|
@@ -1278,7 +1358,13 @@ export declare function normalizeSandboxToHostMessage(payload: unknown): v.SafeP
|
|
|
1278
1358
|
readonly type: v.LiteralSchema<"verification", undefined>;
|
|
1279
1359
|
readonly verification: v.StringSchema<undefined>;
|
|
1280
1360
|
}, undefined>], undefined>, undefined>, undefined>;
|
|
1281
|
-
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.
|
|
1361
|
+
readonly icon: v.OptionalSchema<v.VariantSchema<"type", [v.LooseObjectSchema<{
|
|
1362
|
+
readonly type: v.LiteralSchema<"icon", undefined>;
|
|
1363
|
+
readonly icon: v.LooseObjectSchema<{
|
|
1364
|
+
readonly name: v.StringSchema<undefined>;
|
|
1365
|
+
readonly color: v.OptionalSchema<v.GenericSchema<import("../protocol/index.js").NotionIconColor>, undefined>;
|
|
1366
|
+
}, undefined>;
|
|
1367
|
+
}, undefined>, v.ObjectSchema<{
|
|
1282
1368
|
readonly type: v.LiteralSchema<"emoji", undefined>;
|
|
1283
1369
|
readonly emoji: v.StringSchema<undefined>;
|
|
1284
1370
|
}, undefined>, v.ObjectSchema<{
|
|
@@ -1318,6 +1404,7 @@ export declare function normalizeSandboxToHostMessage(payload: unknown): v.SafeP
|
|
|
1318
1404
|
readonly height: v.SchemaWithPipe<readonly [v.NumberSchema<undefined>, v.FiniteAction<number, undefined>, v.MinValueAction<number, 0, undefined>]>;
|
|
1319
1405
|
}, undefined>, v.ObjectSchema<{
|
|
1320
1406
|
readonly type: v.LiteralSchema<"invalidHostMessage", undefined>;
|
|
1407
|
+
readonly requestId: v.OptionalSchema<v.StringSchema<undefined>, undefined>;
|
|
1321
1408
|
readonly reason: v.StringSchema<undefined>;
|
|
1322
1409
|
}, undefined>], undefined>>;
|
|
1323
1410
|
//# sourceMappingURL=normalizeSandboxToHostMessage.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizeSandboxToHostMessage.d.ts","sourceRoot":"","sources":["../../src/compatibility/normalizeSandboxToHostMessage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,OAAO
|
|
1
|
+
{"version":3,"file":"normalizeSandboxToHostMessage.d.ts","sourceRoot":"","sources":["../../src/compatibility/normalizeSandboxToHostMessage.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,CAAC,MAAM,SAAS,CAAA;AAE5B;;;GAGG;AACH,wBAAgB,6BAA6B,CAAC,OAAO,EAAE,OAAO;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;4BAE7D"}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { NotionPageIcon } from "../../protocol/pages/pageAppearance.js";
|
|
2
|
+
/** Converts native icons for legacy receivers. Delete when the runtime minimum reaches 9. */
|
|
3
|
+
export declare function toIconForProtocol3To8(icon: NotionPageIcon | null): NotionPageIcon | null;
|
|
4
|
+
//# sourceMappingURL=toIconForProtocol3To8.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"toIconForProtocol3To8.d.ts","sourceRoot":"","sources":["../../../src/compatibility/pages/toIconForProtocol3To8.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,0DAA0D,CAAA;AAE9F,6FAA6F;AAC7F,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,cAAc,GAAG,IAAI,GACzB,cAAc,GAAG,IAAI,CAWvB"}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
/** Converts native icons for legacy receivers. Delete when the runtime minimum reaches 9. */
|
|
2
|
+
export function toIconForProtocol3To8(icon) {
|
|
3
|
+
if (icon?.type !== "icon") {
|
|
4
|
+
return icon;
|
|
5
|
+
}
|
|
6
|
+
const { name, color } = icon.icon;
|
|
7
|
+
return {
|
|
8
|
+
type: "external",
|
|
9
|
+
external: {
|
|
10
|
+
url: `https://www.notion.so/icons/${name}_${color ?? "gray"}.svg`,
|
|
11
|
+
},
|
|
12
|
+
};
|
|
13
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"toPageForProtocol3To5.d.ts","sourceRoot":"","sources":["../../../src/compatibility/protocol3To5/toPageForProtocol3To5.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2EAA2E,CAAA;AAC1H,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sDAAsD,CAAA;
|
|
1
|
+
{"version":3,"file":"toPageForProtocol3To5.d.ts","sourceRoot":"","sources":["../../../src/compatibility/protocol3To5/toPageForProtocol3To5.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,2EAA2E,CAAA;AAC1H,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,sDAAsD,CAAA;AAGtF;;;;;;;GAOG;AACH,wBAAgB,qBAAqB,CACpC,IAAI,EAAE,UAAU,GACd,yBAAyB,CAe3B"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toIconForProtocol3To8 } from "../pages/toIconForProtocol3To8.js";
|
|
1
2
|
/**
|
|
2
3
|
* Converts current page data to the page-operation format used by protocols 3–5.
|
|
3
4
|
* Keys property objects by raw ID and omits null properties. Optional icons,
|
|
@@ -10,7 +11,7 @@ export function toPageForProtocol3To5(page) {
|
|
|
10
11
|
return {
|
|
11
12
|
...page,
|
|
12
13
|
properties: Object.fromEntries(Object.values(page.properties).flatMap(property => property ? [[property.id, property]] : [])),
|
|
13
|
-
icon: page.icon ?? undefined,
|
|
14
|
+
icon: toIconForProtocol3To8(page.icon) ?? undefined,
|
|
14
15
|
cover: page.cover ?? undefined,
|
|
15
16
|
created_time: page.created_time ?? undefined,
|
|
16
17
|
last_edited_time: page.last_edited_time ?? undefined,
|
|
@@ -48,11 +48,11 @@ export declare function toQueryPageForProtocol3To5(page: BridgePage): {
|
|
|
48
48
|
value: number;
|
|
49
49
|
time: string;
|
|
50
50
|
defaultTimeZone?: string | undefined;
|
|
51
|
-
} | {
|
|
52
|
-
unit: "none";
|
|
53
51
|
} | {
|
|
54
52
|
unit: "hour" | "minute";
|
|
55
53
|
value: number;
|
|
54
|
+
} | {
|
|
55
|
+
unit: "none";
|
|
56
56
|
} | undefined;
|
|
57
57
|
} | {
|
|
58
58
|
type: "datetimerange";
|
|
@@ -66,11 +66,11 @@ export declare function toQueryPageForProtocol3To5(page: BridgePage): {
|
|
|
66
66
|
value: number;
|
|
67
67
|
time: string;
|
|
68
68
|
defaultTimeZone?: string | undefined;
|
|
69
|
-
} | {
|
|
70
|
-
unit: "none";
|
|
71
69
|
} | {
|
|
72
70
|
unit: "hour" | "minute";
|
|
73
71
|
value: number;
|
|
72
|
+
} | {
|
|
73
|
+
unit: "none";
|
|
74
74
|
} | undefined;
|
|
75
75
|
} | undefined;
|
|
76
76
|
last_edited_time: string | number | boolean | string[] | {
|
|
@@ -109,11 +109,11 @@ export declare function toQueryPageForProtocol3To5(page: BridgePage): {
|
|
|
109
109
|
value: number;
|
|
110
110
|
time: string;
|
|
111
111
|
defaultTimeZone?: string | undefined;
|
|
112
|
-
} | {
|
|
113
|
-
unit: "none";
|
|
114
112
|
} | {
|
|
115
113
|
unit: "hour" | "minute";
|
|
116
114
|
value: number;
|
|
115
|
+
} | {
|
|
116
|
+
unit: "none";
|
|
117
117
|
} | undefined;
|
|
118
118
|
} | {
|
|
119
119
|
type: "datetimerange";
|
|
@@ -127,11 +127,11 @@ export declare function toQueryPageForProtocol3To5(page: BridgePage): {
|
|
|
127
127
|
value: number;
|
|
128
128
|
time: string;
|
|
129
129
|
defaultTimeZone?: string | undefined;
|
|
130
|
-
} | {
|
|
131
|
-
unit: "none";
|
|
132
130
|
} | {
|
|
133
131
|
unit: "hour" | "minute";
|
|
134
132
|
value: number;
|
|
133
|
+
} | {
|
|
134
|
+
unit: "none";
|
|
135
135
|
} | undefined;
|
|
136
136
|
} | undefined;
|
|
137
137
|
created_by: {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"normalizePageResultsForProtocol6.d.ts","sourceRoot":"","sources":["../../../src/compatibility/protocol6/normalizePageResultsForProtocol6.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4DAA4D,CAAA;
|
|
1
|
+
{"version":3,"file":"normalizePageResultsForProtocol6.d.ts","sourceRoot":"","sources":["../../../src/compatibility/protocol6/normalizePageResultsForProtocol6.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,4DAA4D,CAAA;AAEtG,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAIlE;;;;GAIG;AACH,wBAAgB,gCAAgC,CAC/C,OAAO,EAAE,oBAAoB,GAC3B,oBAAoB,CAWtB"}
|
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { toIconForProtocol3To8 } from "../pages/toIconForProtocol3To8.js";
|
|
1
2
|
import { toPageWithNullTextFallbackProperties } from "../pages/toPageWithNullTextFallbackProperties.js";
|
|
2
3
|
/**
|
|
3
4
|
* Encodes protocol 6 pages, whose receivers require null for text fallback properties.
|
|
@@ -8,11 +9,17 @@ export function normalizePageResultsForProtocol6(message) {
|
|
|
8
9
|
if (message.type === "queryDataSourceResult") {
|
|
9
10
|
return {
|
|
10
11
|
...message,
|
|
11
|
-
items: message.items.map(
|
|
12
|
+
items: message.items.map(toPageForProtocol6),
|
|
12
13
|
};
|
|
13
14
|
}
|
|
14
15
|
return {
|
|
15
16
|
...message,
|
|
16
|
-
page:
|
|
17
|
+
page: toPageForProtocol6(message.page),
|
|
18
|
+
};
|
|
19
|
+
}
|
|
20
|
+
function toPageForProtocol6(page) {
|
|
21
|
+
return {
|
|
22
|
+
...toPageWithNullTextFallbackProperties(page),
|
|
23
|
+
icon: toIconForProtocol3To8(page.icon),
|
|
17
24
|
};
|
|
18
25
|
}
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import type { SuccessfulPageResult } from "../pages/pageResult.js";
|
|
2
|
+
/** Encodes icons for protocols 7–8. Delete when the runtime minimum reaches 9. */
|
|
3
|
+
export declare function normalizePageResultsForProtocol7To8(message: SuccessfulPageResult): SuccessfulPageResult;
|
|
4
|
+
//# sourceMappingURL=normalizePageResultsForProtocol7To8.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"normalizePageResultsForProtocol7To8.d.ts","sourceRoot":"","sources":["../../../src/compatibility/protocol7To8/normalizePageResultsForProtocol7To8.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,wBAAwB,CAAA;AAGlE,kFAAkF;AAClF,wBAAgB,mCAAmC,CAClD,OAAO,EAAE,oBAAoB,GAC3B,oBAAoB,CAStB"}
|