@docling/docling-components
Version:
Web components for displaying Docling output.
488 lines (442 loc) • 46.1 kB
JavaScript
(function(a,_){typeof exports=="object"&&typeof module<"u"?_(exports):typeof define=="function"&&define.amd?define(["exports"],_):(a=typeof globalThis<"u"?globalThis:a||self,_(a.DoclingComponents={}))})(this,function(a){"use strict";/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/var Bt;const _=r=>(t,e)=>{e!==void 0?e.addInitializer(()=>{customElements.define(r,t)}):customElements.define(r,t)};/**
* @license
* Copyright 2019 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const X=globalThis,at=X.ShadowRoot&&(X.ShadyCSS===void 0||X.ShadyCSS.nativeShadow)&&"adoptedStyleSheets"in Document.prototype&&"replace"in CSSStyleSheet.prototype,lt=Symbol(),wt=new WeakMap;let Pt=class{constructor(t,e,s){if(this._$cssResult$=!0,s!==lt)throw Error("CSSResult is not constructable. Use `unsafeCSS` or `css` instead.");this.cssText=t,this.t=e}get styleSheet(){let t=this.o;const e=this.t;if(at&&t===void 0){const s=e!==void 0&&e.length===1;s&&(t=wt.get(e)),t===void 0&&((this.o=t=new CSSStyleSheet).replaceSync(this.cssText),s&&wt.set(e,t))}return t}toString(){return this.cssText}};const qt=r=>new Pt(typeof r=="string"?r:r+"",void 0,lt),A=(r,...t)=>{const e=r.length===1?r[0]:t.reduce((s,i,n)=>s+(o=>{if(o._$cssResult$===!0)return o.cssText;if(typeof o=="number")return o;throw Error("Value passed to 'css' function must be a 'css' function result: "+o+". Use 'unsafeCSS' to pass non-literal values, but take care to ensure page security.")})(i)+r[n+1],r[0]);return new Pt(e,r,lt)},Vt=(r,t)=>{if(at)r.adoptedStyleSheets=t.map(e=>e instanceof CSSStyleSheet?e:e.styleSheet);else for(const e of t){const s=document.createElement("style"),i=X.litNonce;i!==void 0&&s.setAttribute("nonce",i),s.textContent=e.cssText,r.appendChild(s)}},At=at?r=>r:r=>r instanceof CSSStyleSheet?(t=>{let e="";for(const s of t.cssRules)e+=s.cssText;return qt(e)})(r):r;/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const{is:Wt,defineProperty:Ft,getOwnPropertyDescriptor:Gt,getOwnPropertyNames:Kt,getOwnPropertySymbols:Jt,getPrototypeOf:Zt}=Object,E=globalThis,It=E.trustedTypes,Xt=It?It.emptyScript:"",ht=E.reactiveElementPolyfillSupport,q=(r,t)=>r,Y={toAttribute(r,t){switch(t){case Boolean:r=r?Xt:null;break;case Object:case Array:r=r==null?r:JSON.stringify(r)}return r},fromAttribute(r,t){let e=r;switch(t){case Boolean:e=r!==null;break;case Number:e=r===null?null:Number(r);break;case Object:case Array:try{e=JSON.parse(r)}catch{e=null}}return e}},Q=(r,t)=>!Wt(r,t),Ct={attribute:!0,type:String,converter:Y,reflect:!1,useDefault:!1,hasChanged:Q};Symbol.metadata??(Symbol.metadata=Symbol("metadata")),E.litPropertyMetadata??(E.litPropertyMetadata=new WeakMap);let R=class extends HTMLElement{static addInitializer(t){this._$Ei(),(this.l??(this.l=[])).push(t)}static get observedAttributes(){return this.finalize(),this._$Eh&&[...this._$Eh.keys()]}static createProperty(t,e=Ct){if(e.state&&(e.attribute=!1),this._$Ei(),this.prototype.hasOwnProperty(t)&&((e=Object.create(e)).wrapped=!0),this.elementProperties.set(t,e),!e.noAccessor){const s=Symbol(),i=this.getPropertyDescriptor(t,s,e);i!==void 0&&Ft(this.prototype,t,i)}}static getPropertyDescriptor(t,e,s){const{get:i,set:n}=Gt(this.prototype,t)??{get(){return this[e]},set(o){this[e]=o}};return{get:i,set(o){const l=i==null?void 0:i.call(this);n==null||n.call(this,o),this.requestUpdate(t,l,s)},configurable:!0,enumerable:!0}}static getPropertyOptions(t){return this.elementProperties.get(t)??Ct}static _$Ei(){if(this.hasOwnProperty(q("elementProperties")))return;const t=Zt(this);t.finalize(),t.l!==void 0&&(this.l=[...t.l]),this.elementProperties=new Map(t.elementProperties)}static finalize(){if(this.hasOwnProperty(q("finalized")))return;if(this.finalized=!0,this._$Ei(),this.hasOwnProperty(q("properties"))){const e=this.properties,s=[...Kt(e),...Jt(e)];for(const i of s)this.createProperty(i,e[i])}const t=this[Symbol.metadata];if(t!==null){const e=litPropertyMetadata.get(t);if(e!==void 0)for(const[s,i]of e)this.elementProperties.set(s,i)}this._$Eh=new Map;for(const[e,s]of this.elementProperties){const i=this._$Eu(e,s);i!==void 0&&this._$Eh.set(i,e)}this.elementStyles=this.finalizeStyles(this.styles)}static finalizeStyles(t){const e=[];if(Array.isArray(t)){const s=new Set(t.flat(1/0).reverse());for(const i of s)e.unshift(At(i))}else t!==void 0&&e.push(At(t));return e}static _$Eu(t,e){const s=e.attribute;return s===!1?void 0:typeof s=="string"?s:typeof t=="string"?t.toLowerCase():void 0}constructor(){super(),this._$Ep=void 0,this.isUpdatePending=!1,this.hasUpdated=!1,this._$Em=null,this._$Ev()}_$Ev(){var t;this._$ES=new Promise(e=>this.enableUpdating=e),this._$AL=new Map,this._$E_(),this.requestUpdate(),(t=this.constructor.l)==null||t.forEach(e=>e(this))}addController(t){var e;(this._$EO??(this._$EO=new Set)).add(t),this.renderRoot!==void 0&&this.isConnected&&((e=t.hostConnected)==null||e.call(t))}removeController(t){var e;(e=this._$EO)==null||e.delete(t)}_$E_(){const t=new Map,e=this.constructor.elementProperties;for(const s of e.keys())this.hasOwnProperty(s)&&(t.set(s,this[s]),delete this[s]);t.size>0&&(this._$Ep=t)}createRenderRoot(){const t=this.shadowRoot??this.attachShadow(this.constructor.shadowRootOptions);return Vt(t,this.constructor.elementStyles),t}connectedCallback(){var t;this.renderRoot??(this.renderRoot=this.createRenderRoot()),this.enableUpdating(!0),(t=this._$EO)==null||t.forEach(e=>{var s;return(s=e.hostConnected)==null?void 0:s.call(e)})}enableUpdating(t){}disconnectedCallback(){var t;(t=this._$EO)==null||t.forEach(e=>{var s;return(s=e.hostDisconnected)==null?void 0:s.call(e)})}attributeChangedCallback(t,e,s){this._$AK(t,s)}_$ET(t,e){var n;const s=this.constructor.elementProperties.get(t),i=this.constructor._$Eu(t,s);if(i!==void 0&&s.reflect===!0){const o=(((n=s.converter)==null?void 0:n.toAttribute)!==void 0?s.converter:Y).toAttribute(e,s.type);this._$Em=t,o==null?this.removeAttribute(i):this.setAttribute(i,o),this._$Em=null}}_$AK(t,e){var n,o;const s=this.constructor,i=s._$Eh.get(t);if(i!==void 0&&this._$Em!==i){const l=s.getPropertyOptions(i),h=typeof l.converter=="function"?{fromAttribute:l.converter}:((n=l.converter)==null?void 0:n.fromAttribute)!==void 0?l.converter:Y;this._$Em=i,this[i]=h.fromAttribute(e,l.type)??((o=this._$Ej)==null?void 0:o.get(i))??null,this._$Em=null}}requestUpdate(t,e,s){var i;if(t!==void 0){const n=this.constructor,o=this[t];if(s??(s=n.getPropertyOptions(t)),!((s.hasChanged??Q)(o,e)||s.useDefault&&s.reflect&&o===((i=this._$Ej)==null?void 0:i.get(t))&&!this.hasAttribute(n._$Eu(t,s))))return;this.C(t,e,s)}this.isUpdatePending===!1&&(this._$ES=this._$EP())}C(t,e,{useDefault:s,reflect:i,wrapped:n},o){s&&!(this._$Ej??(this._$Ej=new Map)).has(t)&&(this._$Ej.set(t,o??e??this[t]),n!==!0||o!==void 0)||(this._$AL.has(t)||(this.hasUpdated||s||(e=void 0),this._$AL.set(t,e)),i===!0&&this._$Em!==t&&(this._$Eq??(this._$Eq=new Set)).add(t))}async _$EP(){this.isUpdatePending=!0;try{await this._$ES}catch(e){Promise.reject(e)}const t=this.scheduleUpdate();return t!=null&&await t,!this.isUpdatePending}scheduleUpdate(){return this.performUpdate()}performUpdate(){var s;if(!this.isUpdatePending)return;if(!this.hasUpdated){if(this.renderRoot??(this.renderRoot=this.createRenderRoot()),this._$Ep){for(const[n,o]of this._$Ep)this[n]=o;this._$Ep=void 0}const i=this.constructor.elementProperties;if(i.size>0)for(const[n,o]of i){const{wrapped:l}=o,h=this[n];l!==!0||this._$AL.has(n)||h===void 0||this.C(n,void 0,o,h)}}let t=!1;const e=this._$AL;try{t=this.shouldUpdate(e),t?(this.willUpdate(e),(s=this._$EO)==null||s.forEach(i=>{var n;return(n=i.hostUpdate)==null?void 0:n.call(i)}),this.update(e)):this._$EM()}catch(i){throw t=!1,this._$EM(),i}t&&this._$AE(e)}willUpdate(t){}_$AE(t){var e;(e=this._$EO)==null||e.forEach(s=>{var i;return(i=s.hostUpdated)==null?void 0:i.call(s)}),this.hasUpdated||(this.hasUpdated=!0,this.firstUpdated(t)),this.updated(t)}_$EM(){this._$AL=new Map,this.isUpdatePending=!1}get updateComplete(){return this.getUpdateComplete()}getUpdateComplete(){return this._$ES}shouldUpdate(t){return!0}update(t){this._$Eq&&(this._$Eq=this._$Eq.forEach(e=>this._$ET(e,this[e]))),this._$EM()}updated(t){}firstUpdated(t){}};R.elementStyles=[],R.shadowRootOptions={mode:"open"},R[q("elementProperties")]=new Map,R[q("finalized")]=new Map,ht==null||ht({ReactiveElement:R}),(E.reactiveElementVersions??(E.reactiveElementVersions=[])).push("2.1.0");/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const Yt={attribute:!0,type:String,converter:Y,reflect:!1,hasChanged:Q},Qt=(r=Yt,t,e)=>{const{kind:s,metadata:i}=e;let n=globalThis.litPropertyMetadata.get(i);if(n===void 0&&globalThis.litPropertyMetadata.set(i,n=new Map),s==="setter"&&((r=Object.create(r)).wrapped=!0),n.set(e.name,r),s==="accessor"){const{name:o}=e;return{set(l){const h=t.get.call(this);t.set.call(this,l),this.requestUpdate(o,h,r)},init(l){return l!==void 0&&this.C(o,void 0,r,l),l}}}if(s==="setter"){const{name:o}=e;return function(l){const h=this[o];t.call(this,l),this.requestUpdate(o,h,r)}}throw Error("Unsupported decorator location: "+s)};function u(r){return(t,e)=>typeof e=="object"?Qt(r,t,e):((s,i,n)=>{const o=i.hasOwnProperty(n);return i.constructor.createProperty(n,s),o?Object.getOwnPropertyDescriptor(i,n):void 0})(r,t,e)}const ct=[];function pt(r){const t=_(r);return function(e,s){return ct.push(e),t(e,s)}}/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const V=globalThis,tt=V.trustedTypes,Ot=tt?tt.createPolicy("lit-html",{createHTML:r=>r}):void 0,Tt="$lit$",S=`lit$${Math.random().toFixed(9).slice(2)}$`,Et="?"+S,te=`<${Et}>`,U=document,W=()=>U.createComment(""),F=r=>r===null||typeof r!="object"&&typeof r!="function",dt=Array.isArray,ee=r=>dt(r)||typeof(r==null?void 0:r[Symbol.iterator])=="function",ut=`[
\f\r]`,G=/<(?:(!--|\/[^a-zA-Z])|(\/?[a-zA-Z][^>\s]*)|(\/?$))/g,St=/-->/g,Dt=/>/g,M=RegExp(`>|${ut}(?:([^\\s"'>=/]+)(${ut}*=${ut}*(?:[^
\f\r"'\`<>=]|("|')|))|$)`,"g"),jt=/'/g,kt=/"/g,Ut=/^(?:script|style|textarea|title)$/i,Mt=r=>(t,...e)=>({_$litType$:r,strings:t,values:e}),g=Mt(1),et=Mt(2),z=Symbol.for("lit-noChange"),$=Symbol.for("lit-nothing"),Nt=new WeakMap,N=U.createTreeWalker(U,129);function Ht(r,t){if(!dt(r)||!r.hasOwnProperty("raw"))throw Error("invalid template strings array");return Ot!==void 0?Ot.createHTML(t):t}const ie=(r,t)=>{const e=r.length-1,s=[];let i,n=t===2?"<svg>":t===3?"<math>":"",o=G;for(let l=0;l<e;l++){const h=r[l];let p,d,c=-1,m=0;for(;m<h.length&&(o.lastIndex=m,d=o.exec(h),d!==null);)m=o.lastIndex,o===G?d[1]==="!--"?o=St:d[1]!==void 0?o=Dt:d[2]!==void 0?(Ut.test(d[2])&&(i=RegExp("</"+d[2],"g")),o=M):d[3]!==void 0&&(o=M):o===M?d[0]===">"?(o=i??G,c=-1):d[1]===void 0?c=-2:(c=o.lastIndex-d[2].length,p=d[1],o=d[3]===void 0?M:d[3]==='"'?kt:jt):o===kt||o===jt?o=M:o===St||o===Dt?o=G:(o=M,i=void 0);const f=o===M&&r[l+1].startsWith("/>")?" ":"";n+=o===G?h+te:c>=0?(s.push(p),h.slice(0,c)+Tt+h.slice(c)+S+f):h+S+(c===-2?l:f)}return[Ht(r,n+(r[e]||"<?>")+(t===2?"</svg>":t===3?"</math>":"")),s]};class K{constructor({strings:t,_$litType$:e},s){let i;this.parts=[];let n=0,o=0;const l=t.length-1,h=this.parts,[p,d]=ie(t,e);if(this.el=K.createElement(p,s),N.currentNode=this.el.content,e===2||e===3){const c=this.el.content.firstChild;c.replaceWith(...c.childNodes)}for(;(i=N.nextNode())!==null&&h.length<l;){if(i.nodeType===1){if(i.hasAttributes())for(const c of i.getAttributeNames())if(c.endsWith(Tt)){const m=d[o++],f=i.getAttribute(c).split(S),b=/([.?@])?(.*)/.exec(m);h.push({type:1,index:n,name:b[2],strings:f,ctor:b[1]==="."?re:b[1]==="?"?ne:b[1]==="@"?oe:it}),i.removeAttribute(c)}else c.startsWith(S)&&(h.push({type:6,index:n}),i.removeAttribute(c));if(Ut.test(i.tagName)){const c=i.textContent.split(S),m=c.length-1;if(m>0){i.textContent=tt?tt.emptyScript:"";for(let f=0;f<m;f++)i.append(c[f],W()),N.nextNode(),h.push({type:2,index:++n});i.append(c[m],W())}}}else if(i.nodeType===8)if(i.data===Et)h.push({type:2,index:n});else{let c=-1;for(;(c=i.data.indexOf(S,c+1))!==-1;)h.push({type:7,index:n}),c+=S.length-1}n++}}static createElement(t,e){const s=U.createElement("template");return s.innerHTML=t,s}}function B(r,t,e=r,s){var o,l;if(t===z)return t;let i=s!==void 0?(o=e._$Co)==null?void 0:o[s]:e._$Cl;const n=F(t)?void 0:t._$litDirective$;return(i==null?void 0:i.constructor)!==n&&((l=i==null?void 0:i._$AO)==null||l.call(i,!1),n===void 0?i=void 0:(i=new n(r),i._$AT(r,e,s)),s!==void 0?(e._$Co??(e._$Co=[]))[s]=i:e._$Cl=i),i!==void 0&&(t=B(r,i._$AS(r,t.values),i,s)),t}class se{constructor(t,e){this._$AV=[],this._$AN=void 0,this._$AD=t,this._$AM=e}get parentNode(){return this._$AM.parentNode}get _$AU(){return this._$AM._$AU}u(t){const{el:{content:e},parts:s}=this._$AD,i=((t==null?void 0:t.creationScope)??U).importNode(e,!0);N.currentNode=i;let n=N.nextNode(),o=0,l=0,h=s[0];for(;h!==void 0;){if(o===h.index){let p;h.type===2?p=new J(n,n.nextSibling,this,t):h.type===1?p=new h.ctor(n,h.name,h.strings,this,t):h.type===6&&(p=new ae(n,this,t)),this._$AV.push(p),h=s[++l]}o!==(h==null?void 0:h.index)&&(n=N.nextNode(),o++)}return N.currentNode=U,i}p(t){let e=0;for(const s of this._$AV)s!==void 0&&(s.strings!==void 0?(s._$AI(t,s,e),e+=s.strings.length-2):s._$AI(t[e])),e++}}class J{get _$AU(){var t;return((t=this._$AM)==null?void 0:t._$AU)??this._$Cv}constructor(t,e,s,i){this.type=2,this._$AH=$,this._$AN=void 0,this._$AA=t,this._$AB=e,this._$AM=s,this.options=i,this._$Cv=(i==null?void 0:i.isConnected)??!0}get parentNode(){let t=this._$AA.parentNode;const e=this._$AM;return e!==void 0&&(t==null?void 0:t.nodeType)===11&&(t=e.parentNode),t}get startNode(){return this._$AA}get endNode(){return this._$AB}_$AI(t,e=this){t=B(this,t,e),F(t)?t===$||t==null||t===""?(this._$AH!==$&&this._$AR(),this._$AH=$):t!==this._$AH&&t!==z&&this._(t):t._$litType$!==void 0?this.$(t):t.nodeType!==void 0?this.T(t):ee(t)?this.k(t):this._(t)}O(t){return this._$AA.parentNode.insertBefore(t,this._$AB)}T(t){this._$AH!==t&&(this._$AR(),this._$AH=this.O(t))}_(t){this._$AH!==$&&F(this._$AH)?this._$AA.nextSibling.data=t:this.T(U.createTextNode(t)),this._$AH=t}$(t){var n;const{values:e,_$litType$:s}=t,i=typeof s=="number"?this._$AC(t):(s.el===void 0&&(s.el=K.createElement(Ht(s.h,s.h[0]),this.options)),s);if(((n=this._$AH)==null?void 0:n._$AD)===i)this._$AH.p(e);else{const o=new se(i,this),l=o.u(this.options);o.p(e),this.T(l),this._$AH=o}}_$AC(t){let e=Nt.get(t.strings);return e===void 0&&Nt.set(t.strings,e=new K(t)),e}k(t){dt(this._$AH)||(this._$AH=[],this._$AR());const e=this._$AH;let s,i=0;for(const n of t)i===e.length?e.push(s=new J(this.O(W()),this.O(W()),this,this.options)):s=e[i],s._$AI(n),i++;i<e.length&&(this._$AR(s&&s._$AB.nextSibling,i),e.length=i)}_$AR(t=this._$AA.nextSibling,e){var s;for((s=this._$AP)==null?void 0:s.call(this,!1,!0,e);t&&t!==this._$AB;){const i=t.nextSibling;t.remove(),t=i}}setConnected(t){var e;this._$AM===void 0&&(this._$Cv=t,(e=this._$AP)==null||e.call(this,t))}}class it{get tagName(){return this.element.tagName}get _$AU(){return this._$AM._$AU}constructor(t,e,s,i,n){this.type=1,this._$AH=$,this._$AN=void 0,this.element=t,this.name=e,this._$AM=i,this.options=n,s.length>2||s[0]!==""||s[1]!==""?(this._$AH=Array(s.length-1).fill(new String),this.strings=s):this._$AH=$}_$AI(t,e=this,s,i){const n=this.strings;let o=!1;if(n===void 0)t=B(this,t,e,0),o=!F(t)||t!==this._$AH&&t!==z,o&&(this._$AH=t);else{const l=t;let h,p;for(t=n[0],h=0;h<n.length-1;h++)p=B(this,l[s+h],e,h),p===z&&(p=this._$AH[h]),o||(o=!F(p)||p!==this._$AH[h]),p===$?t=$:t!==$&&(t+=(p??"")+n[h+1]),this._$AH[h]=p}o&&!i&&this.j(t)}j(t){t===$?this.element.removeAttribute(this.name):this.element.setAttribute(this.name,t??"")}}class re extends it{constructor(){super(...arguments),this.type=3}j(t){this.element[this.name]=t===$?void 0:t}}class ne extends it{constructor(){super(...arguments),this.type=4}j(t){this.element.toggleAttribute(this.name,!!t&&t!==$)}}class oe extends it{constructor(t,e,s,i,n){super(t,e,s,i,n),this.type=5}_$AI(t,e=this){if((t=B(this,t,e,0)??$)===z)return;const s=this._$AH,i=t===$&&s!==$||t.capture!==s.capture||t.once!==s.once||t.passive!==s.passive,n=t!==$&&(s===$||i);i&&this.element.removeEventListener(this.name,this,s),n&&this.element.addEventListener(this.name,this,t),this._$AH=t}handleEvent(t){var e;typeof this._$AH=="function"?this._$AH.call(((e=this.options)==null?void 0:e.host)??this.element,t):this._$AH.handleEvent(t)}}class ae{constructor(t,e,s){this.element=t,this.type=6,this._$AN=void 0,this._$AM=e,this.options=s}get _$AU(){return this._$AM._$AU}_$AI(t){B(this,t)}}const mt=V.litHtmlPolyfillSupport;mt==null||mt(K,J),(V.litHtmlVersions??(V.litHtmlVersions=[])).push("3.3.0");const le=(r,t,e)=>{const s=(e==null?void 0:e.renderBefore)??t;let i=s._$litPart$;if(i===void 0){const n=(e==null?void 0:e.renderBefore)??null;s._$litPart$=i=new J(t.insertBefore(W(),n),n,void 0,e??{})}return i._$AI(r),i};/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const H=globalThis;let w=class extends R{constructor(){super(...arguments),this.renderOptions={host:this},this._$Do=void 0}createRenderRoot(){var e;const t=super.createRenderRoot();return(e=this.renderOptions).renderBefore??(e.renderBefore=t.firstChild),t}update(t){const e=this.render();this.hasUpdated||(this.renderOptions.isConnected=this.isConnected),super.update(t),this._$Do=le(e,this.renderRoot,this.renderOptions)}connectedCallback(){var t;super.connectedCallback(),(t=this._$Do)==null||t.setConnected(!0)}disconnectedCallback(){var t;super.disconnectedCallback(),(t=this._$Do)==null||t.setConnected(!1)}render(){return z}};w._$litElement$=!0,w.finalized=!0,(Bt=H.litElementHydrateSupport)==null||Bt.call(H,{LitElement:w});const gt=H.litElementPolyfillSupport;gt==null||gt({LitElement:w}),(H.litElementVersions??(H.litElementVersions=[])).push("4.2.0");var he=Object.defineProperty,st=(r,t,e,s)=>{for(var i=void 0,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(t,e,i)||i);return i&&he(t,e,i),i};class D extends w{render(){if(this.annotation&&this.item&&this.page&&this.canDrawAnnotation(this.annotation)&&this.canDrawItem(this.item))return this.renderAnnotation(this.annotation,this.item,this.page,this.prov)}}st([u({attribute:!1})],D.prototype,"annotation"),st([u({attribute:!1})],D.prototype,"item"),st([u({attribute:!1})],D.prototype,"page"),st([u({attribute:!1})],D.prototype,"prov");function L(...r){return function(t){return v.DocItem(t)&&r.includes(t.label)}}var O={CodeItem:L("code"),ListItem:L("list_item"),PictureItem:L("chart","picture"),SectionHeaderItem:L("section_header"),TableItem:L("document_index","table"),TextItem:L("caption","checkbox_selected","checkbox_unselected","footnote","page_footer","page_header","paragraph","reference","text")};function T(...r){return function(t){return r.includes(t.kind)}}var ft={PictureBarChart:T("bar_chart_data"),PictureClassification:T("classification"),PictureDescription:T("description"),PictureMisc:T("misc"),PictureMolecule:T("molecule_data"),PictureLineChart:T("line_chart_data"),PicturePieChart:T("pie_chart_data"),PictureScatterChart:T("scatter_chart_data"),PictureStackedBarChart:T("stacked_bar_chart_data")},v={DocItem(r){return v.NodeItem(r)&&!v.GroupItem(r)},Document(r){return"schema_name"in r&&r.schema_name==="DoclingDocument"},GroupItem(r){return v.NodeItem(r)&&(r.self_ref.startsWith("#/groups/")||r.self_ref==="#/body")},NodeItem(r){return"self_ref"in r},...ft,...O};function*ce(r,t={}){r&&(yield*e(t.root??r.body));function*e(s,i=0){var n;if((!v.GroupItem(s)||t.withGroups)&&(v.DocItem(s)?(t.pageNo===void 0||(n=s.prov)!=null&&n.some(o=>o.page_no===t.pageNo))&&(yield[s,i]):yield[s,i]),!(v.PictureItem(s)&&!t.traversePictures))for(const o of s.children??[]){const l=pe(r,o);v.NodeItem(l)&&(yield*e(l,i+1))}}}function pe(r,t){return t.$ref.split("/").slice(1).reduce((s,i)=>s[i],r)}var de=Object.defineProperty,ue=Object.getOwnPropertyDescriptor,xt=(r,t,e,s)=>{for(var i=s>1?void 0:s?ue(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&de(t,e,i),i};a.AnnotationPictureClassification=class extends D{constructor(){super(...arguments),this.precision=2}renderAnnotation(t,e,s,i){const n=t.predicted_classes??[],o=Math.pow(10,-1*this.precision),l=n.filter(d=>o<d.confidence),h=n.filter(d=>d.confidence<o),p=d=>d.toLocaleString(void 0,{maximumFractionDigits:this.precision});return g`<table>
<thead>
<tr>
<th>Class</th>
<th>Confidence</th>
</tr>
</thead>
<tbody>
${l.map(({class_name:d,confidence:c})=>g`<tr>
<td>${d}</td>
<td>${p(c)}</td>
</tr>`)}
${h.length===0?$:g`<tr
class="more"
title=${h.map(d=>`${d.class_name} ${d.confidence}`).join(`
`)}
>
<td>${h.length} more</td>
<td>< ${p(o)}</td>
</tr>`}
</tbody>
</table>`}canDrawAnnotation(t){return ft.PictureClassification(t)}canDrawItem(t){return O.PictureItem(t)}},a.AnnotationPictureClassification.styles=A`
table {
margin: 0.5rem;
font-size: inherit;
line-height: 1.25;
}
td,
th {
padding: 0 1rem 0 0;
}
th {
font-weight: bold;
text-align: left;
}
tr.more td {
padding-top: 0.25rem;
color: gray;
}
`,xt([u()],a.AnnotationPictureClassification.prototype,"precision",2),a.AnnotationPictureClassification=xt([pt("docling-picture-classification")],a.AnnotationPictureClassification);var me=Object.getOwnPropertyDescriptor,ge=(r,t,e,s)=>{for(var i=s>1?void 0:s?me(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(i)||i);return i};a.AnnotationPictureDescription=class extends D{renderAnnotation(t,e,s,i){return g`<p><span>Description</span>${t.text}</p>`}canDrawAnnotation(t){return ft.PictureDescription(t)}canDrawItem(t){return O.PictureItem(t)}},a.AnnotationPictureDescription.styles=A`
p {
margin: 0.5rem;
font-size: inherit;
line-height: 1.25;
white-space: pre-line;
}
span {
padding-right: 0.5rem;
font-weight: bold;
}
`,a.AnnotationPictureDescription=ge([pt("docling-picture-description")],a.AnnotationPictureDescription);const $t=[];function _t(r){const t=_(r);return function(e,s){return $t.push(e),t(e,s)}}var fe=Object.defineProperty,yt=(r,t,e,s)=>{for(var i=void 0,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(t,e,i)||i);return i&&fe(t,e,i),i};class I extends w{render(){if(this.item&&this.page&&this.canDrawItem(this.item))return this.renderItem(this.item,this.page,this.prov)}}yt([u({attribute:!1})],I.prototype,"item"),yt([u({attribute:!1})],I.prototype,"page"),yt([u({attribute:!1})],I.prototype,"prov");var $e=Object.getOwnPropertyDescriptor,_e=(r,t,e,s)=>{for(var i=s>1?void 0:s?$e(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(i)||i);return i};a.ItemProvenance=class extends I{renderItem(t,e){var n;const{image:s}=e,i=(n=t.prov)==null?void 0:n.find(o=>{var l;return o.page_no===((l=this.page)==null?void 0:l.page_no)});if(s&&i){const{width:o=1,height:l=1}=this.page.size,{l:h,r:p,t:d,b:c}=x(i.bbox,e);return g`
<svg
width=${(p-h)*((s.size.width??1)/o)}
viewBox="${h} ${d} ${p-h} ${c-d}"
>
<image href=${s.uri} width=${o} height=${l} />
</svg>
`}else return g`<span>Invalid provenance.</span>`}canDrawItem(t){return v.DocItem(t)}},a.ItemProvenance.styles=A`
svg {
max-width: 100%;
}
`,a.ItemProvenance=_e([_("docling-item-provenance")],a.ItemProvenance);var ye=Object.getOwnPropertyDescriptor,be=(r,t,e,s)=>{for(var i=s>1?void 0:s?ye(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(i)||i);return i};a.ItemTable=class extends I{renderItem(t){const e=new Set;return g`
<div class="container">
<table>
<tbody>
${t.data.grid.map(i=>g`<tr>
${i.map(n=>{if(!s(n))return g`<td
class=${n.column_header||n.row_header?"header":""}
colspan=${n.col_span??1}
rowspan=${n.row_span??1}
>
${n.text}
</td>`})}
</tr>`)}
</tbody>
</table>
</div>
`;function s(i){const n=e.has([i.start_col_offset_idx,i.start_row_offset_idx].join());if(!n)for(let o=i.start_col_offset_idx;o<i.end_col_offset_idx;o++)for(let l=i.start_row_offset_idx;l<i.end_row_offset_idx;l++)e.add([o,l].join());return n}}canDrawItem(t){return O.TableItem(t)}},a.ItemTable.styles=A`
.container {
position: relative;
min-width: 0;
max-width: 100%;
min-height: 0;
overflow: auto;
}
table {
border-collapse: collapse;
font-size: 75%;
line-height: 1.25;
}
td {
padding: 0.125rem 0.25rem;
background-color: var(--cds-layer);
border: 1px solid rgb(220, 220, 220);
color: black;
text-decoration: none;
word-break: normal;
text-align: left;
}
td.header {
font-weight: bold;
}
td:hover {
filter: brightness(95%);
}
td:target {
outline: 3px solid blue;
}
`,a.ItemTable=be([_t("docling-item-table")],a.ItemTable);var ve=Object.getOwnPropertyDescriptor,we=(r,t,e,s)=>{for(var i=s>1?void 0:s?ve(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(i)||i);return i};a.ItemTemplate=class extends I{constructor(){super(...arguments),this.renderItem=Function("item","page",`"use strict"; return this.html\`${this.innerHTML}\`;`).bind({html:g})}canDrawItem(t){return v.DocItem(t)}},a.ItemTemplate=we([_("docling-item-template")],a.ItemTemplate);var Pe=Object.getOwnPropertyDescriptor,Ae=(r,t,e,s)=>{for(var i=s>1?void 0:s?Pe(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(i)||i);return i};a.ItemText=class extends I{renderItem(t,e,s){const i=O.SectionHeaderItem(t)?"header":"";if(s){const{l:n,r:o,t:l,b:h}=x(s.bbox,e),p=Math.sqrt((o-n)*(h-l)/t.text.length),d=Math.min(Math.floor(1.25*p),(h-l)/1.25),[c,m]=s.charspan??[0,t.text.length],f=t.text.substring(c,m);return g`<p
class=${i}
style="font-size: ${d}px; line-height: ${1.25*d}px"
>
${f}
</p>`}else return g`<p class=${i}>${t.text}</p>`}canDrawItem(t){return O.TextItem(t)||O.SectionHeaderItem(t)||O.ListItem(t)}},a.ItemText.styles=A`
p {
margin: 0;
overflow-wrap: anywhere;
font-size: 1rem;
line-height: 1.25rem;
}
.header {
font-weight: bold;
}
`,a.ItemText=Ae([_t("docling-item-text")],a.ItemText);var Ie=Object.getOwnPropertyDescriptor,bt=(r,t,e,s)=>{for(var i=s>1?void 0:s?Ie(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(i)||i);return i};a.ItemView=class extends I{get itemChildren(){return Array.from(this.childNodes??[]).filter(t=>t instanceof I)}get annotationChildren(){return Array.from(this.childNodes).filter(t=>t instanceof D)}get isCustomized(){return this.itemChildren.length>0||this.annotationChildren.length>0}renderItem(t,e,s){const i=[],n=this.isCustomized;n?this.itemChildren.filter(l=>l.canDrawItem(t)).forEach(l=>i.push(l)):$t.filter(l=>l.prototype.canDrawItem(t)).forEach(l=>i.push(new l));const o=t.annotations??[];for(const l of o){const h=[];n?this.annotationChildren.filter(p=>p.canDrawItem(p)&&p.canDrawAnnotation(l)).forEach(p=>h.push(p.cloneNode(!0))):ct.filter(p=>p.prototype.canDrawItem(t)&&p.prototype.canDrawAnnotation(l)).forEach(p=>h.push(new p));for(const p of h)p.annotation=l;i.push(...h)}for(const l of i)l.item=t,l.page=e,l.prov=s;return g`${i}`}canDrawItem(t){return v.DocItem(t)&&this.isCustomized?this.itemChildren.some(e=>e.canDrawItem(t))||this.annotationChildren.some(e=>{var s;return e.canDrawItem(t)&&((s=t.annotations)==null?void 0:s.some(i=>e.canDrawAnnotation(i)))}):$t.some(e=>e.prototype.canDrawItem(t))||ct.some(e=>{var s;return e.prototype.canDrawItem(t)&&((s=t.annotations)==null?void 0:s.some(i=>e.prototype.canDrawAnnotation(i)))})}},a.ItemView=bt([_("docling-view")],a.ItemView),a.ItemOverlay=class extends a.ItemView{constructor(){super(...arguments),this.type="overlay"}},a.ItemOverlay=bt([_("docling-overlay")],a.ItemOverlay),a.ItemTooltip=class extends a.ItemView{constructor(){super(...arguments),this.type="tooltip"}},a.ItemTooltip=bt([_("docling-tooltip")],a.ItemTooltip);function x(r,t){const{height:e=1}=t.size;return r.coord_origin==="TOPLEFT"?r:{...r,t:e-r.t,b:e-r.b}}var Ce=Object.defineProperty,Oe=Object.getOwnPropertyDescriptor,P=(r,t,e,s)=>{for(var i=s>1?void 0:s?Oe(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&Ce(t,e,i),i};a.ImgPage=class extends w{constructor(){super(...arguments),this.pagenumbers=!1}render(){var t,e,s;if((t=this.page)!=null&&t.image){const{image:i,size:n,page_no:o}=this.page,{width:l=1,height:h=1}=n,p=this.onClickItem&&this.page?(d,c)=>{var m;return(m=this.onClickItem)==null?void 0:m.call(this,d,this.page,c)}:void 0;return g`
<div class="page" @onclick=${d=>p==null?void 0:p(d)}>
<svg
class="base"
width=${i.size.width}
viewBox="0 0 ${l} ${h}"
>
${this.backdrop?et`
<image
class="backdrop"
href=${i.uri}
width=${l}
height=${h}
/>
<clippath id="clip-page-${o}">
${(e=this.items)==null?void 0:e.map(d=>{var m;const c=(m=d.prov)==null?void 0:m.find(f=>f.page_no===o);if(c){const{l:f,r:b,t:y,b:nt}=x(c.bbox,this.page);return et`<rect
x=${f}
y=${y}
width=${b-f}
height=${nt-y}
/>`}})}
</clippath>
`:$}
<image
id="image"
href=${i.uri}
clip-path="url(#clip-page-${o})"
width=${l}
height=${h}
/>
${(s=this.items)==null?void 0:s.flatMap(d=>(d.prov??[]).filter(c=>c.page_no===o).map(c=>{var nt;const{l:m,r:f,t:b,b:y}=x(c.bbox,this.page);return et`
${this.layOver(d,c)}
<rect
part=${"item"+(this.itemPart?" "+this.itemPart(this.page,d):"")}
style=${(nt=this.itemStyle)==null?void 0:nt.call(this,this.page,d)}
x=${m}
y=${b}
width=${f-m}
height=${y-b}
vector-effect="non-scaling-stroke"
@click=${ot=>{ot.stopPropagation(),p==null||p(ot,d)}}
@mouseenter=${ot=>{const Z=ot.currentTarget.getBoundingClientRect(),Lt=[Z.top*window.innerWidth,(window.innerWidth-Z.right)*window.innerHeight,(window.innerHeight-Z.bottom)*window.innerWidth,Z.left*window.innerHeight],Le=Math.max(...Lt),qe=Lt.findIndex(Ve=>Ve===Le);this.attachTooltip(d,c,Z,qe)}}
@mouseleave=${()=>this.removeTooltip()}
/>
`}))}
</svg>
${this.renderTrace()}
${this.pagenumbers?g`<header
part="page-number-top"
class="page-number-top"
title="Page ${o}"
>
${o}
</header>
<header
part="page-number-bottom"
class="page-number-bottom"
title="Page ${o}"
>
${o}
</header>`:$}
</div>
`}else return g`Invalid page image.`}layOver(t,e){var s;if((s=this.overlay)!=null&&s.canDrawItem(t)){const i=this.overlay.cloneNode(!0);i.item=t,i.page=this.page,i.prov=e;const{l:n,r:o,t:l,b:h}=x(e.bbox,this.page),p=O.PictureItem(t)?"softOverlay":"hardOverlay";return et`<foreignObject part="overlay" class=${p} x=${n} y=${l} width=${o-n} height=${h-l}>${i}</foreignObject>`}}attachTooltip(t,e,s,i){var n;if((n=this.tooltip)!=null&&n.canDrawItem(t)){const o=this.tooltip.cloneNode(!0);o.id="tooltip",o.setAttribute("part","tooltip"),o.className="tooltip",o.setAttribute("style",`
${i===1?`left: ${s.right}px`:i===3?`right: ${window.outerWidth-s.left}px`:`left: calc(${s.left}px - 2rem)`};
${i===0?`bottom: ${window.innerHeight-s.top}px`:i===2?`top: ${s.bottom}px`:`top: calc(${s.top}px - 2rem)`};
max-width: ${2*Math.max(e.bbox.r-e.bbox.l,200)}px;
`),o.item=t,o.page=this.page,this.renderRoot.appendChild(o)}}removeTooltip(){var t;(t=this.renderRoot.querySelector("#tooltip"))==null||t.remove()}renderTrace(){if(this.trace){const t=this.trace.cloneNode(!0);return t.page=this.page,t.items=this.items,t}}},a.ImgPage.styles=A`
.page {
position: relative;
width: fit-content;
color: black;
}
.base {
max-width: 100%;
}
svg:not(.base) {
position: absolute;
inset: 0;
}
.backdrop {
opacity: 0.3;
}
.page-number-top,
.page-number-bottom {
position: absolute;
left: 0;
width: fit-content;
padding: 0 0.25rem;
font-size: 0.75rem;
line-height: 1rem;
color: rgb(120, 120, 120);
mix-blend-mode: difference;
}
.page-number-top {
top: 0;
}
.page-number-bottom {
bottom: 0;
}
rect {
fill: blue;
fill-opacity: 0.0001; /* To activate hover. */
stroke: grey;
stroke-width: 1px;
stroke-dasharray: 1;
cursor: pointer;
}
rect:hover {
fill-opacity: 0.1;
stroke: blue;
}
rect:target {
stroke: blue;
stroke-width: 3px;
stroke-dasharray: none;
}
.hardOverlay,
.softOverlay {
font-size: 62.5%;
background-color: white;
}
.softOverlay {
opacity: 0.9;
}
.tooltip {
position: fixed;
z-index: 100;
padding: 1rem;
margin: 1rem;
background: white;
border: 1px solid rgb(230, 230, 230);
box-shadow: 0 0.5rem 1rem 0 rgba(0, 0, 0, 0.2);
}
`,P([u({type:Object})],a.ImgPage.prototype,"page",2),P([u({type:Array})],a.ImgPage.prototype,"items",2),P([u({type:Boolean})],a.ImgPage.prototype,"pagenumbers",2),P([u()],a.ImgPage.prototype,"itemPart",2),P([u()],a.ImgPage.prototype,"itemStyle",2),P([u()],a.ImgPage.prototype,"onClickItem",2),P([u({type:Boolean})],a.ImgPage.prototype,"backdrop",2),P([u({type:Object})],a.ImgPage.prototype,"overlay",2),P([u({type:Object})],a.ImgPage.prototype,"tooltip",2),P([u({type:Object})],a.ImgPage.prototype,"trace",2),a.ImgPage=P([_("docling-img-page")],a.ImgPage);/**
* @license
* Copyright 2017 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const Te=Symbol();class Rt{get taskComplete(){return this.t||(this.i===1?this.t=new Promise((t,e)=>{this.o=t,this.h=e}):this.i===3?this.t=Promise.reject(this.l):this.t=Promise.resolve(this.u)),this.t}constructor(t,e,s){var n;this.p=0,this.i=0,(this._=t).addController(this);const i=typeof e=="object"?e:{task:e,args:s};this.v=i.task,this.j=i.args,this.m=i.argsEqual??Ee,this.k=i.onComplete,this.A=i.onError,this.autoRun=i.autoRun??!0,"initialValue"in i&&(this.u=i.initialValue,this.i=2,this.O=(n=this.T)==null?void 0:n.call(this))}hostUpdate(){this.autoRun===!0&&this.S()}hostUpdated(){this.autoRun==="afterUpdate"&&this.S()}T(){if(this.j===void 0)return;const t=this.j();if(!Array.isArray(t))throw Error("The args function must return an array");return t}async S(){const t=this.T(),e=this.O;this.O=t,t===e||t===void 0||e!==void 0&&this.m(e,t)||await this.run(t)}async run(t){var o,l,h,p,d;let e,s;t??(t=this.T()),this.O=t,this.i===1?(o=this.q)==null||o.abort():(this.t=void 0,this.o=void 0,this.h=void 0),this.i=1,this.autoRun==="afterUpdate"?queueMicrotask(()=>this._.requestUpdate()):this._.requestUpdate();const i=++this.p;this.q=new AbortController;let n=!1;try{e=await this.v(t,{signal:this.q.signal})}catch(c){n=!0,s=c}if(this.p===i){if(e===Te)this.i=0;else{if(n===!1){try{(l=this.k)==null||l.call(this,e)}catch{}this.i=2,(h=this.o)==null||h.call(this,e)}else{try{(p=this.A)==null||p.call(this,s)}catch{}this.i=3,(d=this.h)==null||d.call(this,s)}this.u=e,this.l=s}this._.requestUpdate()}}abort(t){var e;this.i===1&&((e=this.q)==null||e.abort(t))}get value(){return this.u}get error(){return this.l}get status(){return this.i}render(t){var e,s,i,n;switch(this.i){case 0:return(e=t.initial)==null?void 0:e.call(t);case 1:return(s=t.pending)==null?void 0:s.call(t);case 2:return(i=t.complete)==null?void 0:i.call(t,this.value);case 3:return(n=t.error)==null?void 0:n.call(t,this.error);default:throw Error("Unexpected status: "+this.i)}}}const Ee=(r,t)=>r===t||r.length===t.length&&r.every((e,s)=>!Q(e,t[s]));function Se(r){return Object.values((r==null?void 0:r.pages)??{}).sort((t,e)=>t.page_no-e.page_no)}async function zt(r,t={}){var h,p,d;let e;typeof r=="string"?e=await(await fetch(r)).json():typeof r=="object"&&v.Document(r)&&(e=r);const s=Se(e),i=Array.from(ce(e,{traversePictures:!0})).map(([c])=>c);let n=i;const o=new Set;if(typeof t.items=="string"){const c=new Set(t.items.split(",").map(m=>m.trim()).filter(m=>m.length>0));if(c.size>0){n=[];for(const m of i){const f=m.self_ref.split("/"),b=[];for(let y=2;y<f.length+1;y++)b.push(f.slice(0,y).join("/"));(h=m.prov)==null||h.forEach(y=>b.push(`#/pages/${y.page_no}`)),b.some(y=>c.has(y))?n.push(m):(p=m.prov)==null||p.forEach(y=>o.add(y.page_no))}}}else if(Array.isArray(t.items)){n=[];const c=new Set(t.items);for(const m of i)c.has(m)?n.push(m):(d=m.prov)==null||d.forEach(f=>o.add(f.page_no))}const l={};for(const c of s)l[c.page_no]=[];for(const c of n)for(const m of c.prov??[])l[m.page_no].at(-1)!==c&&l[m.page_no].push(c);return s.map(c=>({page:c,items:l[c.page_no],trimmed:o.has(c.page_no)}))}var De=Object.defineProperty,je=Object.getOwnPropertyDescriptor,vt=(r,t,e,s)=>{for(var i=s>1?void 0:s?je(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&De(t,e,i),i};a.ImgTrace=class extends w{render(){if(this.page&&this.items&&this.items.length>0){const{page_no:t,size:e}=this.page,{width:s=1,height:i=1}=e,n=this.items.map(l=>{var p,d;const h=x((d=(p=l.prov)==null?void 0:p.find(c=>c.page_no===t))==null?void 0:d.bbox,this.page);return[(h.l+h.r)/2,(h.t+h.b)/2]}),o=`M${n[0][0]} 0 ${n.slice(0).map(l=>`L${l[0]} ${l[1]}`)} L${n.at(-1)[0]} ${i}`;return g`<svg viewBox="0 0 ${s} ${i}">
<marker
id="arrow"
viewBox="0 0 10 10"
refX="0"
refY="5"
markerWidth="4"
markerHeight="4"
orient="auto"
>
<path d="M 0 0 L 10 5 L 0 10" />
</marker>
<path
class="halo"
vector-effect="non-scaling-stroke"
d=${o}
marker-start="url(#arrow)"
/>
<path
class="trace"
vector-effect="non-scaling-stroke"
d=${o}
marker-start="url(#arrow)"
/>
</svg>`}}},a.ImgTrace.styles=A`
svg {
position: absolute;
inset: 0;
pointer-events: none;
}
.halo {
fill: none;
stroke-width: 5px;
stroke: white;
stroke-linejoin: round;
}
.trace {
fill: none;
stroke-width: 3px;
stroke: rgba(0, 0, 255);
stroke-linejoin: round;
}
marker > path {
fill: rgba(0, 0, 255);
stroke: none;
}
`,vt([u({type:Object})],a.ImgTrace.prototype,"page",2),vt([u({type:Array})],a.ImgTrace.prototype,"items",2),a.ImgTrace=vt([_("docling-trace")],a.ImgTrace);var ke=Object.defineProperty,Ue=Object.getOwnPropertyDescriptor,C=(r,t,e,s)=>{for(var i=s>1?void 0:s?Ue(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&ke(t,e,i),i};a.ImgPages=class extends w{constructor(){super(...arguments),this.src="",this.trim="pages",this.fetchTask=new Rt(this,{task:async([t,e])=>zt(t,{items:e}),args:()=>[this.src,this.items]})}render(){const t=Array.from(this.childNodes);return this.fetchTask.render({pending:()=>g`<p>...</p>`,complete:e=>g`
${e.filter(s=>!this.trim||s.items.length>0).map(({page:s,items:i})=>g`<docling-img-page
part="page"
.page=${s}
.items=${i}
.pagenumbers=${this.pagenumbers!==void 0}
.itemPart=${this.itemPart}
.itemStyle=${this.itemStyle}
.onClickItem=${this.onClickItem}
.backdrop=${this.backdrop!==void 0}
.overlay=${t.find(n=>n instanceof a.ItemOverlay)}
.tooltip=${t.find(n=>n instanceof a.ItemTooltip)}
.trace=${t.find(n=>n instanceof a.ImgTrace)}
/>`)}
`})}},a.ImgPages.styles=A`
:host {
width: fit-content;
display: flex;
flex-direction: column;
align-items: center;
gap: 2px;
color: black;
}
`,C([u()],a.ImgPages.prototype,"alt",2),C([u()],a.ImgPages.prototype,"backdrop",2),C([u()],a.ImgPages.prototype,"items",2),C([u({type:Boolean})],a.ImgPages.prototype,"pagenumbers",2),C([u()],a.ImgPages.prototype,"src",2),C([u()],a.ImgPages.prototype,"trim",2),C([u()],a.ImgPages.prototype,"itemPart",2),C([u()],a.ImgPages.prototype,"itemStyle",2),C([u()],a.ImgPages.prototype,"onClickItem",2),a.ImgPages=C([_("docling-img")],a.ImgPages);/**
* @license
* Copyright 2018 Google LLC
* SPDX-License-Identifier: BSD-3-Clause
*/const Me=r=>r??$;var Ne=Object.defineProperty,He=Object.getOwnPropertyDescriptor,j=(r,t,e,s)=>{for(var i=s>1?void 0:s?He(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&Ne(t,e,i),i};a.TablePage=class extends w{constructor(){super(...arguments),this.columns=[]}render(){var t,e,s,i,n,o,l;return g`
${this.pagenumbers?g`
<tr>
<td
part="page-number-top"
class="page-number"
title="Page ${(t=this.page)==null?void 0:t.page_no}"
colspan=${((e=this.columns)==null?void 0:e.length)??1}
>
${(s=this.page)==null?void 0:s.page_no}
</td>
</tr>
`:$}
${(i=this.items)==null?void 0:i.map(h=>{var p;return g`<tr
part=${"item"+(this.itemPart?" "+this.itemPart(this.page,h):"")}
style=${Me((p=this.itemStyle)==null?void 0:p.call(this,this.page,h))}
>
${this.columns.map(d=>{const c=d.cloneNode(!0);return c.item=h,c.page=this.page,g`
<td
@onclick=${m=>{var f;return(f=this.onClickItem)==null?void 0:f.call(this,m,this.page,h)}}
>
${c}
</td>
`})}
</tr>`})}
${this.pagenumbers?g`<tr>
<td
part="page-number-bottom"
class="page-number"
title="Page ${(n=this.page)==null?void 0:n.page_no}"
colspan=${((o=this.columns)==null?void 0:o.length)??1}
>
${(l=this.page)==null?void 0:l.page_no}
</td>
</tr>`:$}
`}},a.TablePage.styles=A`
:host {
display: table-row-group;
}
tbody {
border-bottom: 1px solid rgb(220, 220, 220);
}
.page-number {
padding: 0.25rem;
background-color: white;
color: rgb(120, 120, 120);
font-size: 0.75rem;
line-height: 1rem;
}
tr {
cursor: pointer;
}
tr:not(:nth-last-child(2)) {
border-bottom: 1px dotted rgb(220, 220, 220);
}
td {
padding: 1rem;
background-color: white;
vertical-align: top;
}
tr:hover td {
filter: brightness(95%);
}
`,j([u({type:Object})],a.TablePage.prototype,"page",2),j([u({type:Array})],a.TablePage.prototype,"items",2),j([u({type:Array})],a.TablePage.prototype,"columns",2),j([u({type:Boolean})],a.TablePage.prototype,"pagenumbers",2),j([u()],a.TablePage.prototype,"itemPart",2),j([u()],a.TablePage.prototype,"itemStyle",2),j([u()],a.TablePage.prototype,"onClickItem",2),a.TablePage=j([_("docling-table-page")],a.TablePage);var xe=Object.getOwnPropertyDescriptor,Re=(r,t,e,s)=>{for(var i=s>1?void 0:s?xe(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=o(i)||i);return i};let rt=class extends a.ItemView{constructor(){super(...arguments),this.type="column"}};rt=Re([_("docling-column")],rt);var ze=Object.defineProperty,Be=Object.getOwnPropertyDescriptor,k=(r,t,e,s)=>{for(var i=s>1?void 0:s?Be(t,e):t,n=r.length-1,o;n>=0;n--)(o=r[n])&&(i=(s?o(t,e,i):o(i))||i);return s&&i&&ze(t,e,i),i};a.TablePages=class extends w{constructor(){super(...arguments),this.src="",this.fetchTask=new Rt(this,{task:async([t,e])=>zt(t,{items:e}),args:()=>[this.src,this.items]})}render(){const t=Array.from(this.childNodes).filter(s=>s.nodeName.toLowerCase().startsWith("docling-column")),e=t.length>0?t:[new rt,new rt];return t.length===0&&e[1].appendChild(new a.ItemProvenance),this.fetchTask.render({pending:()=>g`<p>...</p>`,complete:s=>g`
<table part="pages">
${s.filter(i=>i.items.length>0).map(({page:i,items:n})=>g`<docling-table-page
.page=${i}
.items=${n}
.columns=${e}
.pagenumbers=${this.pagenumbers!==void 0}
.itemPart=${this.itemPart}
.itemStyle=${this.itemStyle}
.onClickItem=${this.onClickItem}
/>`)}
</table>
`})}},a.TablePages.styles=A`
table {
width: 100%;
border-collapse: collapse;
table-layout: fixed;
background-color: white;
}
`,k([u()],a.TablePages.prototype,"alt",2),k([u()],a.TablePages.prototype,"items",2),k([u({type:Boolean})],a.TablePages.prototype,"pagenumbers",2),k([u()],a.TablePages.prototype,"src",2),k([u()],a.TablePages.prototype,"itemPart",2),k([u()],a.TablePages.prototype,"itemStyle",2),k([u()],a.TablePages.prototype,"onClickItem",2),a.TablePages=k([_("docling-table")],a.TablePages),a.DoclingAnnotationElement=D,a.DoclingItemElement=I,a.customDoclingAnnotationElement=pt,a.customDoclingItemElement=_t,a.normalBbox=x,Object.defineProperty(a,Symbol.toStringTag,{value:"Module"})});