@canonry/canonry 7.17.2 → 7.18.1

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.
Files changed (31) hide show
  1. package/assets/agent-workspace/skills/aero/references/portfolio-analysis.md +8 -6
  2. package/assets/agent-workspace/skills/canonry/references/canonry-cli.md +1 -1
  3. package/assets/assets/{AuditHistoryPanel-Dga03Niw.js → AuditHistoryPanel-RAYlf3B4.js} +1 -1
  4. package/assets/assets/{BacklinksPage-CfodWuIt.js → BacklinksPage-BT3j4tQK.js} +1 -1
  5. package/assets/assets/{HistoryPage-BN_vTU5L.js → HistoryPage-BHV_3wbQ.js} +1 -1
  6. package/assets/assets/{MeasurementPropertyPage-CjiyzOmE.js → MeasurementPropertyPage-9UFPKw-i.js} +1 -1
  7. package/assets/assets/ProjectPage-C1_-qiHw.js +8 -0
  8. package/assets/assets/{RunsPage-Ca_ziCGC.js → RunsPage-Cx5yMuzN.js} +1 -1
  9. package/assets/assets/{SettingsPage-SO1xl0d3.js → SettingsPage-DrZ-eswp.js} +1 -1
  10. package/assets/assets/{SiteHealthSection-C9JgRzzs.js → SiteHealthSection-XOUI_75e.js} +3 -3
  11. package/assets/assets/{TrafficPage-DrcbXNQB.js → TrafficPage-DciX-fl5.js} +1 -1
  12. package/assets/assets/{TrafficSourceDetailPage-HDZGKgyd.js → TrafficSourceDetailPage-D1_lnRoS.js} +1 -1
  13. package/assets/assets/{extract-error-message-D48vwe7I.js → extract-error-message-Cw5pcZtv.js} +1 -1
  14. package/assets/assets/{index-BaBHBReI.js → index-DIA9jvMi.js} +21 -21
  15. package/assets/assets/{react-sigma_core.esm.min-DVHs4npB.js → react-sigma_core.esm.min-Cc8jHlvQ.js} +1 -1
  16. package/assets/assets/{v2-overview-adapter-CTEXuiRt.js → v2-overview-adapter-Ca5F20Kr.js} +1 -1
  17. package/assets/index.html +1 -1
  18. package/dist/{chunk-YJS4OE6I.js → chunk-COQOQYRZ.js} +136 -37
  19. package/dist/{chunk-QAIJH74T.js → chunk-EAAM47H6.js} +24 -9
  20. package/dist/{chunk-P2XY5YX7.js → chunk-JMC7CEJB.js} +4 -4
  21. package/dist/{chunk-4EDH2ORA.js → chunk-JUOFNJLV.js} +3 -3
  22. package/dist/{chunk-3LPQ4JV5.js → chunk-PRL6UQ7L.js} +8 -7
  23. package/dist/{chunk-NPNU6UHD.js → chunk-U7D7LNVJ.js} +2 -2
  24. package/dist/{chunk-MIRAKDRW.js → chunk-X2S7D3MN.js} +17 -3
  25. package/dist/cli.js +26 -16
  26. package/dist/{demo-server-54SLPSJF.js → demo-server-XWRIXME5.js} +4 -4
  27. package/dist/index.js +6 -6
  28. package/dist/{intelligence-service-62CEP6M2.js → intelligence-service-332S7D7Y.js} +2 -2
  29. package/dist/mcp.js +4 -4
  30. package/package.json +14 -14
  31. package/assets/assets/ProjectPage-AxclA3YC.js +0 -8
@@ -1,4 +1,4 @@
1
- import{g as Bt,t as S,r as C}from"./vendor-tanstack-ZXXkndVj.js";import{e as Ht,G as Wt}from"./SiteHealthSection-C9JgRzzs.js";import"./index-BaBHBReI.js";import"./vendor-radix-twS1M3FF.js";import"./vendor-recharts-D-cUuLZo.js";import"./vendor-lucide-Y6jANGfG.js";import"./vendor-markdown-B4giJcws.js";import"./vendor-yaml-GWJz5H2G.js";import"./ChartPrimitives-CYlrwLJs.js";function Vt(r,n){if(typeof r!="object"||!r)return r;var i=r[Symbol.toPrimitive];if(i!==void 0){var e=i.call(r,n);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function ae(r){var n=Vt(r,"string");return typeof n=="symbol"?n:n+""}function A(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function He(r,n){for(var i=0;i<n.length;i++){var e=n[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,ae(e.key),e)}}function L(r,n,i){return n&&He(r.prototype,n),i&&He(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r}function Q(r){return Q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Q(r)}function yt(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(yt=function(){return!!r})()}function jt(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Zt(r,n){if(n&&(typeof n=="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return jt(r)}function I(r,n,i){return n=Q(n),Zt(r,yt()?Reflect.construct(n,i||[],Q(r).constructor):n.apply(r,i))}function xe(r,n){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,e){return i.__proto__=e,i},xe(r,n)}function G(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),n&&xe(r,n)}function qt(r){if(Array.isArray(r))return r}function Yt(r,n){var i=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(i!=null){var e,t,a,o,s=[],l=!0,h=!1;try{if(a=(i=i.call(r)).next,n===0){if(Object(i)!==i)return;l=!1}else for(;!(l=(e=a.call(i)).done)&&(s.push(e.value),s.length!==n);l=!0);}catch(u){h=!0,t=u}finally{try{if(!l&&i.return!=null&&(o=i.return(),Object(o)!==o))return}finally{if(h)throw t}}return s}}function Se(r,n){(n==null||n>r.length)&&(n=r.length);for(var i=0,e=Array(n);i<n;i++)e[i]=r[i];return e}function Tt(r,n){if(r){if(typeof r=="string")return Se(r,n);var i={}.toString.call(r).slice(8,-1);return i==="Object"&&r.constructor&&(i=r.constructor.name),i==="Map"||i==="Set"?Array.from(r):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Se(r,n):void 0}}function Xt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
1
+ import{g as Bt,t as S,r as C}from"./vendor-tanstack-ZXXkndVj.js";import{e as Ht,G as Wt}from"./SiteHealthSection-XOUI_75e.js";import"./index-DIA9jvMi.js";import"./vendor-radix-twS1M3FF.js";import"./vendor-recharts-D-cUuLZo.js";import"./vendor-lucide-Y6jANGfG.js";import"./vendor-markdown-B4giJcws.js";import"./vendor-yaml-GWJz5H2G.js";import"./ChartPrimitives-CYlrwLJs.js";function Vt(r,n){if(typeof r!="object"||!r)return r;var i=r[Symbol.toPrimitive];if(i!==void 0){var e=i.call(r,n);if(typeof e!="object")return e;throw new TypeError("@@toPrimitive must return a primitive value.")}return String(r)}function ae(r){var n=Vt(r,"string");return typeof n=="symbol"?n:n+""}function A(r,n){if(!(r instanceof n))throw new TypeError("Cannot call a class as a function")}function He(r,n){for(var i=0;i<n.length;i++){var e=n[i];e.enumerable=e.enumerable||!1,e.configurable=!0,"value"in e&&(e.writable=!0),Object.defineProperty(r,ae(e.key),e)}}function L(r,n,i){return n&&He(r.prototype,n),i&&He(r,i),Object.defineProperty(r,"prototype",{writable:!1}),r}function Q(r){return Q=Object.setPrototypeOf?Object.getPrototypeOf.bind():function(n){return n.__proto__||Object.getPrototypeOf(n)},Q(r)}function yt(){try{var r=!Boolean.prototype.valueOf.call(Reflect.construct(Boolean,[],function(){}))}catch{}return(yt=function(){return!!r})()}function jt(r){if(r===void 0)throw new ReferenceError("this hasn't been initialised - super() hasn't been called");return r}function Zt(r,n){if(n&&(typeof n=="object"||typeof n=="function"))return n;if(n!==void 0)throw new TypeError("Derived constructors may only return object or undefined");return jt(r)}function I(r,n,i){return n=Q(n),Zt(r,yt()?Reflect.construct(n,i||[],Q(r).constructor):n.apply(r,i))}function xe(r,n){return xe=Object.setPrototypeOf?Object.setPrototypeOf.bind():function(i,e){return i.__proto__=e,i},xe(r,n)}function G(r,n){if(typeof n!="function"&&n!==null)throw new TypeError("Super expression must either be null or a function");r.prototype=Object.create(n&&n.prototype,{constructor:{value:r,writable:!0,configurable:!0}}),Object.defineProperty(r,"prototype",{writable:!1}),n&&xe(r,n)}function qt(r){if(Array.isArray(r))return r}function Yt(r,n){var i=r==null?null:typeof Symbol<"u"&&r[Symbol.iterator]||r["@@iterator"];if(i!=null){var e,t,a,o,s=[],l=!0,h=!1;try{if(a=(i=i.call(r)).next,n===0){if(Object(i)!==i)return;l=!1}else for(;!(l=(e=a.call(i)).done)&&(s.push(e.value),s.length!==n);l=!0);}catch(u){h=!0,t=u}finally{try{if(!l&&i.return!=null&&(o=i.return(),Object(o)!==o))return}finally{if(h)throw t}}return s}}function Se(r,n){(n==null||n>r.length)&&(n=r.length);for(var i=0,e=Array(n);i<n;i++)e[i]=r[i];return e}function Tt(r,n){if(r){if(typeof r=="string")return Se(r,n);var i={}.toString.call(r).slice(8,-1);return i==="Object"&&r.constructor&&(i=r.constructor.name),i==="Map"||i==="Set"?Array.from(r):i==="Arguments"||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(i)?Se(r,n):void 0}}function Xt(){throw new TypeError(`Invalid attempt to destructure non-iterable instance.
2
2
  In order to be iterable, non-array objects must have a [Symbol.iterator]() method.`)}function ee(r,n){return qt(r)||Yt(r,n)||Tt(r,n)||Xt()}var pe={black:"#000000",silver:"#C0C0C0",gray:"#808080",grey:"#808080",white:"#FFFFFF",maroon:"#800000",red:"#FF0000",purple:"#800080",fuchsia:"#FF00FF",green:"#008000",lime:"#00FF00",olive:"#808000",yellow:"#FFFF00",navy:"#000080",blue:"#0000FF",teal:"#008080",aqua:"#00FFFF",darkblue:"#00008B",mediumblue:"#0000CD",darkgreen:"#006400",darkcyan:"#008B8B",deepskyblue:"#00BFFF",darkturquoise:"#00CED1",mediumspringgreen:"#00FA9A",springgreen:"#00FF7F",cyan:"#00FFFF",midnightblue:"#191970",dodgerblue:"#1E90FF",lightseagreen:"#20B2AA",forestgreen:"#228B22",seagreen:"#2E8B57",darkslategray:"#2F4F4F",darkslategrey:"#2F4F4F",limegreen:"#32CD32",mediumseagreen:"#3CB371",turquoise:"#40E0D0",royalblue:"#4169E1",steelblue:"#4682B4",darkslateblue:"#483D8B",mediumturquoise:"#48D1CC",indigo:"#4B0082",darkolivegreen:"#556B2F",cadetblue:"#5F9EA0",cornflowerblue:"#6495ED",rebeccapurple:"#663399",mediumaquamarine:"#66CDAA",dimgray:"#696969",dimgrey:"#696969",slateblue:"#6A5ACD",olivedrab:"#6B8E23",slategray:"#708090",slategrey:"#708090",lightslategray:"#778899",lightslategrey:"#778899",mediumslateblue:"#7B68EE",lawngreen:"#7CFC00",chartreuse:"#7FFF00",aquamarine:"#7FFFD4",skyblue:"#87CEEB",lightskyblue:"#87CEFA",blueviolet:"#8A2BE2",darkred:"#8B0000",darkmagenta:"#8B008B",saddlebrown:"#8B4513",darkseagreen:"#8FBC8F",lightgreen:"#90EE90",mediumpurple:"#9370DB",darkviolet:"#9400D3",palegreen:"#98FB98",darkorchid:"#9932CC",yellowgreen:"#9ACD32",sienna:"#A0522D",brown:"#A52A2A",darkgray:"#A9A9A9",darkgrey:"#A9A9A9",lightblue:"#ADD8E6",greenyellow:"#ADFF2F",paleturquoise:"#AFEEEE",lightsteelblue:"#B0C4DE",powderblue:"#B0E0E6",firebrick:"#B22222",darkgoldenrod:"#B8860B",mediumorchid:"#BA55D3",rosybrown:"#BC8F8F",darkkhaki:"#BDB76B",mediumvioletred:"#C71585",indianred:"#CD5C5C",peru:"#CD853F",chocolate:"#D2691E",tan:"#D2B48C",lightgray:"#D3D3D3",lightgrey:"#D3D3D3",thistle:"#D8BFD8",orchid:"#DA70D6",goldenrod:"#DAA520",palevioletred:"#DB7093",crimson:"#DC143C",gainsboro:"#DCDCDC",plum:"#DDA0DD",burlywood:"#DEB887",lightcyan:"#E0FFFF",lavender:"#E6E6FA",darksalmon:"#E9967A",violet:"#EE82EE",palegoldenrod:"#EEE8AA",lightcoral:"#F08080",khaki:"#F0E68C",aliceblue:"#F0F8FF",honeydew:"#F0FFF0",azure:"#F0FFFF",sandybrown:"#F4A460",wheat:"#F5DEB3",beige:"#F5F5DC",whitesmoke:"#F5F5F5",mintcream:"#F5FFFA",ghostwhite:"#F8F8FF",salmon:"#FA8072",antiquewhite:"#FAEBD7",linen:"#FAF0E6",lightgoldenrodyellow:"#FAFAD2",oldlace:"#FDF5E6",magenta:"#FF00FF",deeppink:"#FF1493",orangered:"#FF4500",tomato:"#FF6347",hotpink:"#FF69B4",coral:"#FF7F50",darkorange:"#FF8C00",lightsalmon:"#FFA07A",orange:"#FFA500",lightpink:"#FFB6C1",pink:"#FFC0CB",gold:"#FFD700",peachpuff:"#FFDAB9",navajowhite:"#FFDEAD",moccasin:"#FFE4B5",bisque:"#FFE4C4",mistyrose:"#FFE4E1",blanchedalmond:"#FFEBCD",papayawhip:"#FFEFD5",lavenderblush:"#FFF0F5",seashell:"#FFF5EE",cornsilk:"#FFF8DC",lemonchiffon:"#FFFACD",floralwhite:"#FFFAF0",snow:"#FFFAFA",lightyellow:"#FFFFE0",ivory:"#FFFFF0"},Ct=new Int8Array(4),be=new Int32Array(Ct.buffer,0,1),$t=new Float32Array(Ct.buffer,0,1),Kt=/^\s*rgba?\s*\(/,Jt=/^\s*rgba?\s*\(\s*([0-9]*)\s*,\s*([0-9]*)\s*,\s*([0-9]*)(?:\s*,\s*(.*)?)?\)\s*$/;function Qt(r){var n=0,i=0,e=0,t=1;if(r[0]==="#")r.length===4?(n=parseInt(r.charAt(1)+r.charAt(1),16),i=parseInt(r.charAt(2)+r.charAt(2),16),e=parseInt(r.charAt(3)+r.charAt(3),16)):(n=parseInt(r.charAt(1)+r.charAt(2),16),i=parseInt(r.charAt(3)+r.charAt(4),16),e=parseInt(r.charAt(5)+r.charAt(6),16)),r.length===9&&(t=parseInt(r.charAt(7)+r.charAt(8),16)/255);else if(Kt.test(r)){var a=r.match(Jt);a&&(n=+a[1],i=+a[2],e=+a[3],a[4]&&(t=+a[4]))}return{r:n,g:i,b:e,a:t}}var J={};for(var le in pe)J[le]=oe(pe[le]),J[pe[le]]=J[le];function Rt(r,n,i,e,t){return be[0]=e<<24|i<<16|n<<8|r,be[0]=be[0]&4278190079,$t[0]}function oe(r){if(r=r.toLowerCase(),typeof J[r]<"u")return J[r];var n=Qt(r),i=n.r,e=n.g,t=n.b,a=n.a;a=a*255|0;var o=Rt(i,e,t,a);return J[r]=o,o}var Ee={};function _t(r){if(typeof Ee[r]<"u")return Ee[r];var n=(r&16711680)>>>16,i=(r&65280)>>>8,e=r&255,t=255,a=Rt(n,i,e,t);return Ee[r]=a,a}function We(r,n,i,e){return i+(n<<8)+(r<<16)}function Ve(r,n,i,e,t,a){var o=Math.floor(i/a*t),s=Math.floor(r.drawingBufferHeight/a-e/a*t),l=new Uint8Array(4);r.bindFramebuffer(r.FRAMEBUFFER,n),r.readPixels(o,s,1,1,r.RGBA,r.UNSIGNED_BYTE,l);var h=ee(l,4),u=h[0],d=h[1],f=h[2],g=h[3];return[u,d,f,g]}function c(r,n,i){return(n=ae(n))in r?Object.defineProperty(r,n,{value:i,enumerable:!0,configurable:!0,writable:!0}):r[n]=i,r}function je(r,n){var i=Object.keys(r);if(Object.getOwnPropertySymbols){var e=Object.getOwnPropertySymbols(r);n&&(e=e.filter(function(t){return Object.getOwnPropertyDescriptor(r,t).enumerable})),i.push.apply(i,e)}return i}function b(r){for(var n=1;n<arguments.length;n++){var i=arguments[n]!=null?arguments[n]:{};n%2?je(Object(i),!0).forEach(function(e){c(r,e,i[e])}):Object.getOwnPropertyDescriptors?Object.defineProperties(r,Object.getOwnPropertyDescriptors(i)):je(Object(i)).forEach(function(e){Object.defineProperty(r,e,Object.getOwnPropertyDescriptor(i,e))})}return r}function ei(r,n){for(;!{}.hasOwnProperty.call(r,n)&&(r=Q(r))!==null;);return r}function Ae(){return Ae=typeof Reflect<"u"&&Reflect.get?Reflect.get.bind():function(r,n,i){var e=ei(r,n);if(e){var t=Object.getOwnPropertyDescriptor(e,n);return t.get?t.get.call(arguments.length<3?r:i):t.value}},Ae.apply(null,arguments)}function wt(r,n,i,e){var t=Ae(Q(r.prototype),n,i);return typeof t=="function"?function(a){return t.apply(i,a)}:t}function ti(r){return r.normalized?1:r.size}function ye(r){var n=0;return r.forEach(function(i){return n+=ti(i)}),n}function xt(r,n,i){var e=r==="VERTEX"?n.VERTEX_SHADER:n.FRAGMENT_SHADER,t=n.createShader(e);if(t===null)throw new Error("loadShader: error while creating the shader");n.shaderSource(t,i),n.compileShader(t);var a=n.getShaderParameter(t,n.COMPILE_STATUS);if(!a){var o=n.getShaderInfoLog(t);throw n.deleteShader(t),new Error(`loadShader: error while compiling the shader:
3
3
  `.concat(o,`
4
4
  `).concat(i))}return t}function ii(r,n){return xt("VERTEX",r,n)}function ri(r,n){return xt("FRAGMENT",r,n)}function ni(r,n){var i=r.createProgram();if(i===null)throw new Error("loadProgram: error while creating the program.");var e,t;for(e=0,t=n.length;e<t;e++)r.attachShader(i,n[e]);r.linkProgram(i);var a=r.getProgramParameter(i,r.LINK_STATUS);if(!a){var o=r.getProgramInfoLog(i);throw r.deleteProgram(i),new Error("loadProgram: error while linking the program: ".concat(o))}return i}function Ze(r){var n=r.gl,i=r.buffer,e=r.program,t=r.vertexShader,a=r.fragmentShader;n.deleteShader(t),n.deleteShader(a),n.deleteProgram(e),n.deleteBuffer(i)}var qe=`#define PICKING_MODE
@@ -1 +1 @@
1
- import{r as j,j as i}from"./vendor-tanstack-ZXXkndVj.js";import{_ as ae,eo as oe,B as le,b4 as ue}from"./index-BaBHBReI.js";import{M as ce}from"./vendor-markdown-B4giJcws.js";import{C as de,$ as pe,g as J}from"./vendor-lucide-Y6jANGfG.js";const Ae="Sources",B={copy:"Copy answer",copying:"Copying…",copied:"Copied",failed:"Could not copy. Select and copy the answer above."};function me({previewLength:e,highlight:r}){return o=>{if(e!==void 0&&Number.isFinite(e)){let c=Math.max(0,Math.floor(e));const d={field:"value",omitted:!1},p=n=>{if(n.type==="definition")return!0;if(n.children)return n.children=n.children.filter(p),n.children.length>0;const s=n.type==="image"||n.type==="imageReference"?"alt":"value",f=n[s];if(f===void 0)return c>0;const b=Array.from(f);if(b.length===0)return c>0;if(c===0)return d.omitted=!0,!1;const N=b.length>c,k=b.slice(0,c);if(N&&!/\s/.test(b[c])){let g=k.length-1;for(;g>=0&&!/\s/.test(k[g]);)g--;g>=0&&g>c-40&&(k.length=g)}return d.omitted||=N,n[s]=k.join(""),c=N?0:c-k.length,k.length===0?!1:(d.lastNode=n,d.field=s,!0)};p(o),d.omitted&&(d.lastNode?d.lastNode[d.field]=`${d.lastNode[d.field].trimEnd()}…`:o.children?.push({type:"paragraph",children:[{type:"text",value:"…"}]}))}if(r){const c=d=>{["link","linkReference","code","inlineCode"].includes(d.type)||(d.type==="text"&&(d.data={...d.data,hName:"span"}),d.children?.forEach(c))};c(o)}}}function fe({headingLevel:e}){return r=>{const o=[],c=p=>{p.type==="heading"&&p.depth&&o.push(p),p.children?.forEach(c)};c(r);const d=o.reduce((p,n)=>Math.min(p,n.depth),6);for(const p of o){const n=p.depth-d;p.depth=Math.min(6,e+n),p.data={...p.data,hProperties:{...p.data?.hProperties,"data-answer-heading-level":n+1}}}}}function ge({answer:e}){const[r,o]=j.useState("idle"),c=j.useRef(!1),d=async()=>{if(!c.current){c.current=!0,o("copying");try{await navigator.clipboard.writeText(e),o("copied")}catch{o("failed")}finally{c.current=!1}}};return i.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-3",children:[i.jsx(le,{type:"button",variant:"ghost",className:"min-h-11 px-2","aria-disabled":r==="copying","aria-busy":r==="copying",onClick:()=>{d()},children:r==="copying"?B.copying:B.copy}),i.jsx("span",{role:"status",className:"text-sm text-secondary",children:r==="copied"?B.copied:r==="failed"?B.failed:""})]})}const Se=j.memo(function({children:r,headingLevel:o=4,copyable:c=!1,highlightGroups:d,previewLength:p}){return i.jsxs("div",{className:"answer-markdown",children:[i.jsx(ce,{remarkPlugins:[[fe,{headingLevel:o}],[me,{previewLength:p,highlight:!!d?.length}]],components:{p:({children:n})=>i.jsx("p",{className:"mb-3 whitespace-pre-wrap last:mb-0",children:n}),ul:({children:n})=>i.jsx("ul",{className:"mb-3 ml-5 list-disc space-y-1",children:n}),ol:({children:n,start:s})=>i.jsx("ol",{start:s,className:"mb-3 ml-5 list-decimal space-y-1",children:n}),pre:({children:n})=>i.jsx("pre",{className:"mb-3 overflow-x-auto whitespace-pre-wrap",children:n}),span:({children:n})=>i.jsx("span",{children:typeof n=="string"&&d?n.split(/(https?:\/\/[^\s<>]+)/i).map((s,f)=>f%2?s:i.jsx(j.Fragment,{children:oe(s,d)},f)):n}),a:({children:n,href:s})=>{const f=ae(s);return f?i.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-link underline",children:n}):i.jsx("span",{children:n})},img:({alt:n})=>i.jsx("span",{children:n})},children:r}),c&&r.trim()?i.jsx(ge,{answer:r},r):null]})}),X="min-h-11 w-full rounded-md border border-default bg-surface px-3 py-2 text-sm text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",G="flex min-h-11 w-full items-center justify-between gap-3 rounded px-2 text-left text-sm text-primary hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",E=e=>e.kind==="project"?"Whole site":e.label,q={allMarkets:"All markets",browse:e=>`Browse ${e}`,select:e=>`Select ${e}`,browseAll:"Browse all properties"},he=e=>e?.kind==="group"&&e.marketKeys?.length===1?e.marketKeys[0]:void 0,ee=e=>`${e} ${e===1?"property":"properties"}`;function Ke({options:e,selected:r,onSelect:o,marketKey:c,label:d="Measurement scope",labelVisibility:p="visible",allowGroupSelect:n=!0}){const s=[...e].sort((t,u)=>t.label.localeCompare(u.label,void 0,{numeric:!0})||t.id.localeCompare(u.id)),[f,b]=j.useState(""),[N,k]=j.useState([]),[g,$]=j.useState(!1),C=j.useRef(null),I=j.useRef(null),a=j.useId(),y=s.filter(t=>t.kind==="group"),h=new Map(y.map(t=>[t.id,t])),l=h.get(N.at(-1)??""),F=h.get(N.at(-2)??""),x=f.trim().toLocaleLowerCase(),ne=y.filter(t=>!t.parentGroupIds?.some(u=>h.has(u))),_=s.filter(t=>t.kind==="property"),O=t=>(t.parentGroupIds??[]).map(u=>h.get(u)?.label).filter(Boolean).join(" · "),P=t=>`${E(t)} ${O(t)}`.toLocaleLowerCase().includes(x),U=t=>{const u=[...t.parentGroupIds??[]],m=new Set;for(;u.length;){const v=u.pop();if(v===l?.id)return!0;m.has(v)||(m.add(v),u.push(...h.get(v)?.parentGroupIds??[]))}return!1},A=(g?[]:l?y.filter(t=>x?U(t):t.parentGroupIds?.includes(l.id)):x?y:ne).filter(P),S=s.find(t=>t.kind==="market"&&t.id===(c??(r.kind==="market"?r.id:void 0))),H=l&&S&&(l.marketKeys?.includes(S.id)||S.parentGroupIds?.includes(l.id))?S.id:void 0,L=n?H??he(l):void 0,V=(l?_.filter(t=>t.parentGroupIds?.includes(l.id)&&(!L||t.marketKeys?.includes(L))):x||g||y.length===0?_:[]).filter(P),W=s.filter(t=>t.kind!=="market"||g||!n&&!l&&!x&&y.length>0||n&&l?.marketKeys?.length===1&&!x?!1:(l?x?U(t):t.parentGroupIds?.includes(l.id):x||!t.parentGroupIds?.some(m=>h.has(m)))&&P(t)),Y=l||g?[]:s.filter(t=>t.kind==="project"&&P(t));j.useEffect(()=>{const t=u=>{C.current?.open&&u.target instanceof Node&&!C.current.contains(u.target)&&(C.current.open=!1)};return document.addEventListener("pointerdown",t),()=>document.removeEventListener("pointerdown",t)},[]);const se=t=>{C.current&&(C.current.open=!1,C.current.querySelector("summary")?.focus());const u=n?t.kind==="property"?L:t.kind==="group"&&t.id===l?.id?H:void 0:void 0;u?o(t,u):o(t)},T=t=>{const u=[];let m=h.get(t.parentGroupIds?.[0]??"");for(;m&&!u.includes(m.id)&&m.id!==t.id;)u.unshift(m.id),m=h.get(m.parentGroupIds?.[0]??"");return[...u,t.id]},ie=()=>{const t=r.kind==="group"?h.get(r.id):void 0,u=h.get(S?.parentGroupIds?.[0]??""),m=(r.parentGroupIds??[]).flatMap(K=>{const R=h.get(K);return R?[T(R)]:[]}),v=m.find(K=>K.at(-1)===l?.id)??m.sort((K,R)=>R.length-K.length)[0]??[],Z=u?T(u):r.marketKeys?.length?[]:v;k(t?T(t):Z),$(r.kind==="property"&&Z.length===0&&y.length>0),b("")},z=t=>{k(T(t)),$(!1),b(""),I.current?.focus()},w=(t,u=E(t))=>i.jsxs("div",{className:"flex items-stretch",children:[i.jsxs("button",{type:"button",className:G,"aria-label":t.kind==="group"&&!n?q.browse(E(t)):q.select(E(t)),"aria-current":r.kind===t.kind&&r.id===t.id?"true":void 0,onClick:()=>t.kind==="group"&&!n?z(t):se(t),children:[i.jsxs("span",{className:"min-w-0 break-words",children:[u,x&&O(t)?i.jsx("span",{className:"block text-[13px] text-secondary",children:O(t)}):null]}),i.jsx("span",{className:"shrink-0 text-right text-[13px] text-secondary",children:t.kind==="market"?n?"Query context":"Market":t.kind==="property"?"Property":ee(t.targetCount)})]}),n&&t.kind==="group"&&t.id!==l?.id&&s.some(m=>m.parentGroupIds?.includes(t.id))?i.jsx("button",{type:"button","aria-label":q.browse(t.label),title:`Browse ${t.label}`,className:"flex min-h-11 min-w-11 items-center justify-center rounded text-secondary hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",onClick:()=>z(t),children:i.jsx(J,{size:18,"aria-hidden":"true"})}):null]},`${t.kind}:${t.id}`),D=(t,u)=>u.length>0?i.jsxs("section",{"aria-label":t,className:"mt-2",children:[i.jsx("h3",{className:"px-2 py-2 text-[13px] font-medium text-secondary",children:t}),u.map(m=>w(m))]}):null,Q=(t,u,m)=>u.length>0?i.jsxs("details",{open:m,className:"mt-2 border-y border-default",children:[i.jsxs("summary",{className:"min-h-11 cursor-pointer px-2 py-3 text-sm text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[t," (",u.length,")"]}),u.map(v=>w(v))]},`${l?.id??"root"}:${t}`):null;return i.jsxs("div",{className:"min-w-0",children:[i.jsx("span",{id:`${a}-label`,className:p==="sr-only"?"sr-only":"mb-1 block text-sm font-medium text-heading",children:d}),i.jsxs("details",{ref:C,className:"relative",onToggle:t=>{t.target===t.currentTarget&&t.currentTarget.open&&I.current?.focus()},onKeyDown:t=>{t.key==="Escape"&&(t.preventDefault(),t.currentTarget.open=!1,t.currentTarget.querySelector("summary")?.focus())},children:[i.jsxs("summary",{id:`${a}-value`,"aria-labelledby":`${a}-label ${a}-value`,className:`${X} visibility-scope-trigger`,onClick:()=>{C.current?.open||ie()},children:[`${E(r)}${r.kind==="group"?` · ${ee(r.targetCount)}`:r.kind==="property"?` · ${s.find(t=>t.kind==="market"&&t.id===c)?.label??(r.marketKeys?.length?q.allMarkets:"Property")}`:r.kind==="market"?" · Market":""}`,i.jsx(de,{size:16,"aria-hidden":"true",className:"shrink-0 text-secondary"})]}),i.jsxs("div",{className:"visibility-scope-menu",children:[l||g?i.jsxs("div",{className:"mb-2 border-b border-default pb-2",children:[i.jsx("button",{type:"button",className:G,"aria-label":`Back to ${F?.label??"all groups"}`,onClick:()=>{k(N.slice(0,-1)),$(!1),b(""),I.current?.focus()},children:i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(pe,{size:16,"aria-hidden":"true"}),F?.label??"All groups"]})}),i.jsx("p",{className:"px-2 py-1 text-sm font-medium text-heading","aria-live":"polite",children:l?.label??"All properties"})]}):null,i.jsx("input",{ref:I,type:"search","aria-label":"Search scopes",className:X,placeholder:l?"Search within this group":g?"Search properties":"Search groups or properties",value:f,onChange:t=>b(t.target.value)}),i.jsxs("div",{className:"mt-2 max-h-80 overflow-y-auto",children:[n&&l&&!x?w(l,"All properties in this group"):null,Y.map(t=>w(t)),l&&!x?Q("Subgroups",A,!0):D(l?"Subgroups":"Groups",A),x?D("Properties",V):Q(l&&A.length>0?"All properties":"Properties",V,!l||A.length===0),D("Markets",W),!l&&!g&&!x&&y.length>0&&_.length>0?i.jsxs("button",{type:"button",className:`${G} mt-2 border-t border-default`,"aria-label":q.browseAll,onClick:()=>{$(!0),I.current?.focus()},children:[i.jsx("span",{children:"All properties"}),i.jsx(J,{size:18,"aria-hidden":"true"})]}):null,x&&A.length+V.length+W.length+Y.length===0?i.jsx("p",{className:"py-3 text-sm text-secondary",children:"No matching scopes."}):null]})]})]})]})}function Ee(e){const r=e[0];return r?e.every(o=>o.mode===r.mode&&o.scope.kind===r.scope.kind&&o.scope.key===r.scope.key&&o.queryClass===r.queryClass&&o.measurement.displayedRunId===r.measurement.displayedRunId):!0}function M(e){return e.state==="unavailable"?{numerator:null,denominator:null,reason:e.reason}:e.numerator===void 0||e.denominator===void 0||e.denominator<=0?{numerator:null,denominator:null,reason:"not_applicable"}:{numerator:e.numerator,denominator:e.denominator,...e.unattributed===void 0?{}:{unattributed:e.unattributed},...e.unchecked===void 0?{}:{unchecked:e.unchecked}}}function ye(e){return e.kind==="exact"?e.url:e.kind==="prefix"?`https://${e.host}${e.pathPrefix}/*`:`https://${e.host}/*`}function be(e){return e==="assigned"?"this-property":e==="sibling"?"another-property":e==="ownedUnmapped"?"owned-unassigned":e==="external"?"external":e==="ambiguous"?"multiple-properties":"invalid-url"}function xe(e){return e==="assigned"?"positive":e==="external"?"neutral":e==="invalid"?"negative":"caution"}function te(e){return`target:${e.targetKey}:${e.queryId}:${e.executionNodeKey}`}function ke(e,r,o){const c=new Map;if(!r)return c;const d=new Map(e.usageEdges.map(s=>[te(s),s.targetKey])),p=new Map(e.assignments.map(s=>[`${s.targetKey}:${s.queryId}`,s.queryClass])),n=new Map(e.usageEdges.map(s=>[te(s),p.get(`${s.targetKey}:${s.queryId}`)]));for(const s of r.evidence){if(o&&n.get(s.usageEdgeId)!==o)continue;const f=d.get(s.usageEdgeId);if(!f)continue;const b=c.get(f)??[];b.push({id:`${s.observationId}:${s.expectedSlotId}:${s.usageEdgeId}:${s.sourceUrl}`,kind:be(s.classification),query:s.queryText,provider:s.provider,location:s.location,url:s.sourceUrl,tone:xe(s.classification),historical:s.historical||s.bridged}),c.set(f,b)}return c}function Ce(e){if(e.flags>0)return{label:"Review",tone:"caution"};const r=[e.mentionCoverage,e.citationCoverage].filter(o=>o.state==="unavailable").map(o=>o.reason);return r.includes("no_completed_run")?{label:"Not measured",tone:"neutral"}:r.includes("plan_v1")?{label:"Update setup",tone:"caution"}:r.includes("evidence_incomplete")?{label:"Evidence incomplete",tone:"caution"}:r.includes("identity_ambiguous")?{label:ue.ambiguous,tone:"caution"}:r.includes("no_population")?{label:"No queries",tone:"neutral"}:r.includes("not_applicable")?{label:"Not applicable",tone:"neutral"}:{label:"Complete",tone:"positive"}}function je(e){return e==="complete"?{label:"Complete",tone:"positive"}:e==="partial"?{label:"Partial",tone:"caution"}:e==="queued"?{label:"Queued",tone:"neutral"}:e==="running"?{label:"Running",tone:"neutral"}:e==="failed"?{label:"Failed",tone:"negative"}:{label:"Not measured",tone:"neutral"}}function Ne(e){if(!e)return"";const r=new Date(e);return Number.isFinite(r.getTime())?r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"}):""}function re(e){const r=e.nextAction.count??e.flags.total;if(e.nextAction.kind==="review_flags")return`${r} flagged ${r===1?"result needs":"results need"} review.`;if(e.nextAction.kind==="complete_setup")return"Finish setup.";if(e.nextAction.kind==="republish_setup")return"Setup update required.";if(e.nextAction.kind==="run_measurement")return"Ready to measure."}function qe({overview:e,activePlan:r,report:o,reportState:c=o?"ready":"loading",sort:d}){if(r.plan.schemaVersion!==2||e.mode!=="active-v2")throw new Error("The current overview requires an active version-two setup.");if(e.scope.kind!=="all"&&e.scope.kind!=="group")throw new Error("The current overview requires an All Properties or group scope.");const p=r.plan,n=new Map(p.targets.map(a=>[a.stableKey,a])),s=new Map(p.querySnapshots.map(a=>[a.queryId,a.queryText])),f=new Map;for(const a of p.assignments){if(e.queryClass!=="all"&&a.queryClass!==e.queryClass)continue;const y=s.get(a.queryId);if(!y)continue;const h=f.get(a.targetKey)??new Set;h.add(y),f.set(a.targetKey,h)}const b=o?.revision===r.revision&&o.run?.id===e.measurement.displayedRunId?o:null,N=e.measurement.displayedRunId===void 0||b?"ready":c==="error"||o!=null?"error":"loading",k=ke(p,b,e.queryClass==="all"?void 0:e.queryClass),g=new Map;for(const a of p.groups)for(const y of a.targetKeys)g.has(y)||g.set(y,a.label);const $=e.properties.items.map(a=>{const y=n.get(a.targetKey),h=k.get(a.targetKey)??[];return{id:a.targetKey,name:a.label,mentionCoverage:M(a.mentionCoverage),citationCoverage:M(a.citationCoverage),status:Ce(a),providers:a.providers?.map(l=>({provider:l.provider,mentionCoverage:M(l.mentionCoverage),citationCoverage:M(l.citationCoverage)})),market:g.get(a.targetKey),assignedQueries:[...f.get(a.targetKey)??[]],urls:y?.urlMatchers.map(ye)??[],evidence:h,evidenceState:N,historical:h.some(l=>l.historical)}}),C=e.namedShareOfVoice?.entries.map(a=>({name:a.label,coverage:{numerator:a.credits,denominator:e.namedShareOfVoice.denominator}})),I=e.properties.items.flatMap(a=>a.flags>0?[{id:`property:${a.targetKey}`,property:a.label,summary:`${a.flags} ${a.flags===1?"result needs":"results need"} review.`,tone:"caution",count:a.flags}]:[]);return{classReporting:"available",latestMeasurement:{status:je(e.measurement.state),completedSlots:e.measurement.completed,totalSlots:e.measurement.expected,date:Ne(e.measurement.completedAt),includesBridgedHistory:e.measurement.includesHistoricalData===!0},currentView:{scope:e.scope.kind==="group"?{kind:"group",...e.scope.key?{key:e.scope.key}:{}}:{kind:"all"},queryClass:e.queryClass,aggregate:{metrics:{propertiesMentioned:M(e.metrics.propertiesMentioned),mentionCoverage:M(e.metrics.mentionCoverage),citationCoverage:M(e.metrics.citationCoverage)},properties:$,...C?{shareOfVoice:C}:{}},propertyTotal:e.properties.totalEstimate??$.length,outcomes:e.outcomes,nextCursor:e.properties.nextCursor,...d?{sort:d}:{}},availableGroups:p.groups.map(a=>({id:a.stableKey,label:a.label})),...re(e)?{nextActionText:re(e)}:{},flaggedResultsTotal:e.flags.total,flaggedResults:I}}export{Se as A,q as M,Ke as V,Ae as a,Ee as b,qe as c,ye as m};
1
+ import{r as j,j as i}from"./vendor-tanstack-ZXXkndVj.js";import{_ as ae,eo as oe,B as le,b4 as ue}from"./index-DIA9jvMi.js";import{M as ce}from"./vendor-markdown-B4giJcws.js";import{C as de,$ as pe,g as J}from"./vendor-lucide-Y6jANGfG.js";const Ae="Sources",B={copy:"Copy answer",copying:"Copying…",copied:"Copied",failed:"Could not copy. Select and copy the answer above."};function me({previewLength:e,highlight:r}){return o=>{if(e!==void 0&&Number.isFinite(e)){let c=Math.max(0,Math.floor(e));const d={field:"value",omitted:!1},p=n=>{if(n.type==="definition")return!0;if(n.children)return n.children=n.children.filter(p),n.children.length>0;const s=n.type==="image"||n.type==="imageReference"?"alt":"value",f=n[s];if(f===void 0)return c>0;const b=Array.from(f);if(b.length===0)return c>0;if(c===0)return d.omitted=!0,!1;const N=b.length>c,k=b.slice(0,c);if(N&&!/\s/.test(b[c])){let g=k.length-1;for(;g>=0&&!/\s/.test(k[g]);)g--;g>=0&&g>c-40&&(k.length=g)}return d.omitted||=N,n[s]=k.join(""),c=N?0:c-k.length,k.length===0?!1:(d.lastNode=n,d.field=s,!0)};p(o),d.omitted&&(d.lastNode?d.lastNode[d.field]=`${d.lastNode[d.field].trimEnd()}…`:o.children?.push({type:"paragraph",children:[{type:"text",value:"…"}]}))}if(r){const c=d=>{["link","linkReference","code","inlineCode"].includes(d.type)||(d.type==="text"&&(d.data={...d.data,hName:"span"}),d.children?.forEach(c))};c(o)}}}function fe({headingLevel:e}){return r=>{const o=[],c=p=>{p.type==="heading"&&p.depth&&o.push(p),p.children?.forEach(c)};c(r);const d=o.reduce((p,n)=>Math.min(p,n.depth),6);for(const p of o){const n=p.depth-d;p.depth=Math.min(6,e+n),p.data={...p.data,hProperties:{...p.data?.hProperties,"data-answer-heading-level":n+1}}}}}function ge({answer:e}){const[r,o]=j.useState("idle"),c=j.useRef(!1),d=async()=>{if(!c.current){c.current=!0,o("copying");try{await navigator.clipboard.writeText(e),o("copied")}catch{o("failed")}finally{c.current=!1}}};return i.jsxs("div",{className:"mt-3 flex flex-wrap items-center gap-x-3",children:[i.jsx(le,{type:"button",variant:"ghost",className:"min-h-11 px-2","aria-disabled":r==="copying","aria-busy":r==="copying",onClick:()=>{d()},children:r==="copying"?B.copying:B.copy}),i.jsx("span",{role:"status",className:"text-sm text-secondary",children:r==="copied"?B.copied:r==="failed"?B.failed:""})]})}const Se=j.memo(function({children:r,headingLevel:o=4,copyable:c=!1,highlightGroups:d,previewLength:p}){return i.jsxs("div",{className:"answer-markdown",children:[i.jsx(ce,{remarkPlugins:[[fe,{headingLevel:o}],[me,{previewLength:p,highlight:!!d?.length}]],components:{p:({children:n})=>i.jsx("p",{className:"mb-3 whitespace-pre-wrap last:mb-0",children:n}),ul:({children:n})=>i.jsx("ul",{className:"mb-3 ml-5 list-disc space-y-1",children:n}),ol:({children:n,start:s})=>i.jsx("ol",{start:s,className:"mb-3 ml-5 list-decimal space-y-1",children:n}),pre:({children:n})=>i.jsx("pre",{className:"mb-3 overflow-x-auto whitespace-pre-wrap",children:n}),span:({children:n})=>i.jsx("span",{children:typeof n=="string"&&d?n.split(/(https?:\/\/[^\s<>]+)/i).map((s,f)=>f%2?s:i.jsx(j.Fragment,{children:oe(s,d)},f)):n}),a:({children:n,href:s})=>{const f=ae(s);return f?i.jsx("a",{href:f,target:"_blank",rel:"noopener noreferrer",className:"text-link underline",children:n}):i.jsx("span",{children:n})},img:({alt:n})=>i.jsx("span",{children:n})},children:r}),c&&r.trim()?i.jsx(ge,{answer:r},r):null]})}),X="min-h-11 w-full rounded-md border border-default bg-surface px-3 py-2 text-sm text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",G="flex min-h-11 w-full items-center justify-between gap-3 rounded px-2 text-left text-sm text-primary hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",E=e=>e.kind==="project"?"Whole site":e.label,q={allMarkets:"All markets",browse:e=>`Browse ${e}`,select:e=>`Select ${e}`,browseAll:"Browse all properties"},he=e=>e?.kind==="group"&&e.marketKeys?.length===1?e.marketKeys[0]:void 0,ee=e=>`${e} ${e===1?"property":"properties"}`;function Ke({options:e,selected:r,onSelect:o,marketKey:c,label:d="Measurement scope",labelVisibility:p="visible",allowGroupSelect:n=!0}){const s=[...e].sort((t,u)=>t.label.localeCompare(u.label,void 0,{numeric:!0})||t.id.localeCompare(u.id)),[f,b]=j.useState(""),[N,k]=j.useState([]),[g,$]=j.useState(!1),C=j.useRef(null),I=j.useRef(null),a=j.useId(),y=s.filter(t=>t.kind==="group"),h=new Map(y.map(t=>[t.id,t])),l=h.get(N.at(-1)??""),F=h.get(N.at(-2)??""),x=f.trim().toLocaleLowerCase(),ne=y.filter(t=>!t.parentGroupIds?.some(u=>h.has(u))),_=s.filter(t=>t.kind==="property"),O=t=>(t.parentGroupIds??[]).map(u=>h.get(u)?.label).filter(Boolean).join(" · "),P=t=>`${E(t)} ${O(t)}`.toLocaleLowerCase().includes(x),U=t=>{const u=[...t.parentGroupIds??[]],m=new Set;for(;u.length;){const v=u.pop();if(v===l?.id)return!0;m.has(v)||(m.add(v),u.push(...h.get(v)?.parentGroupIds??[]))}return!1},A=(g?[]:l?y.filter(t=>x?U(t):t.parentGroupIds?.includes(l.id)):x?y:ne).filter(P),S=s.find(t=>t.kind==="market"&&t.id===(c??(r.kind==="market"?r.id:void 0))),H=l&&S&&(l.marketKeys?.includes(S.id)||S.parentGroupIds?.includes(l.id))?S.id:void 0,L=n?H??he(l):void 0,V=(l?_.filter(t=>t.parentGroupIds?.includes(l.id)&&(!L||t.marketKeys?.includes(L))):x||g||y.length===0?_:[]).filter(P),W=s.filter(t=>t.kind!=="market"||g||!n&&!l&&!x&&y.length>0||n&&l?.marketKeys?.length===1&&!x?!1:(l?x?U(t):t.parentGroupIds?.includes(l.id):x||!t.parentGroupIds?.some(m=>h.has(m)))&&P(t)),Y=l||g?[]:s.filter(t=>t.kind==="project"&&P(t));j.useEffect(()=>{const t=u=>{C.current?.open&&u.target instanceof Node&&!C.current.contains(u.target)&&(C.current.open=!1)};return document.addEventListener("pointerdown",t),()=>document.removeEventListener("pointerdown",t)},[]);const se=t=>{C.current&&(C.current.open=!1,C.current.querySelector("summary")?.focus());const u=n?t.kind==="property"?L:t.kind==="group"&&t.id===l?.id?H:void 0:void 0;u?o(t,u):o(t)},T=t=>{const u=[];let m=h.get(t.parentGroupIds?.[0]??"");for(;m&&!u.includes(m.id)&&m.id!==t.id;)u.unshift(m.id),m=h.get(m.parentGroupIds?.[0]??"");return[...u,t.id]},ie=()=>{const t=r.kind==="group"?h.get(r.id):void 0,u=h.get(S?.parentGroupIds?.[0]??""),m=(r.parentGroupIds??[]).flatMap(K=>{const R=h.get(K);return R?[T(R)]:[]}),v=m.find(K=>K.at(-1)===l?.id)??m.sort((K,R)=>R.length-K.length)[0]??[],Z=u?T(u):r.marketKeys?.length?[]:v;k(t?T(t):Z),$(r.kind==="property"&&Z.length===0&&y.length>0),b("")},z=t=>{k(T(t)),$(!1),b(""),I.current?.focus()},w=(t,u=E(t))=>i.jsxs("div",{className:"flex items-stretch",children:[i.jsxs("button",{type:"button",className:G,"aria-label":t.kind==="group"&&!n?q.browse(E(t)):q.select(E(t)),"aria-current":r.kind===t.kind&&r.id===t.id?"true":void 0,onClick:()=>t.kind==="group"&&!n?z(t):se(t),children:[i.jsxs("span",{className:"min-w-0 break-words",children:[u,x&&O(t)?i.jsx("span",{className:"block text-[13px] text-secondary",children:O(t)}):null]}),i.jsx("span",{className:"shrink-0 text-right text-[13px] text-secondary",children:t.kind==="market"?n?"Query context":"Market":t.kind==="property"?"Property":ee(t.targetCount)})]}),n&&t.kind==="group"&&t.id!==l?.id&&s.some(m=>m.parentGroupIds?.includes(t.id))?i.jsx("button",{type:"button","aria-label":q.browse(t.label),title:`Browse ${t.label}`,className:"flex min-h-11 min-w-11 items-center justify-center rounded text-secondary hover:bg-surface-hover focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",onClick:()=>z(t),children:i.jsx(J,{size:18,"aria-hidden":"true"})}):null]},`${t.kind}:${t.id}`),D=(t,u)=>u.length>0?i.jsxs("section",{"aria-label":t,className:"mt-2",children:[i.jsx("h3",{className:"px-2 py-2 text-[13px] font-medium text-secondary",children:t}),u.map(m=>w(m))]}):null,Q=(t,u,m)=>u.length>0?i.jsxs("details",{open:m,className:"mt-2 border-y border-default",children:[i.jsxs("summary",{className:"min-h-11 cursor-pointer px-2 py-3 text-sm text-primary focus-visible:outline-none focus-visible:ring-2 focus-visible:ring-mono-400",children:[t," (",u.length,")"]}),u.map(v=>w(v))]},`${l?.id??"root"}:${t}`):null;return i.jsxs("div",{className:"min-w-0",children:[i.jsx("span",{id:`${a}-label`,className:p==="sr-only"?"sr-only":"mb-1 block text-sm font-medium text-heading",children:d}),i.jsxs("details",{ref:C,className:"relative",onToggle:t=>{t.target===t.currentTarget&&t.currentTarget.open&&I.current?.focus()},onKeyDown:t=>{t.key==="Escape"&&(t.preventDefault(),t.currentTarget.open=!1,t.currentTarget.querySelector("summary")?.focus())},children:[i.jsxs("summary",{id:`${a}-value`,"aria-labelledby":`${a}-label ${a}-value`,className:`${X} visibility-scope-trigger`,onClick:()=>{C.current?.open||ie()},children:[`${E(r)}${r.kind==="group"?` · ${ee(r.targetCount)}`:r.kind==="property"?` · ${s.find(t=>t.kind==="market"&&t.id===c)?.label??(r.marketKeys?.length?q.allMarkets:"Property")}`:r.kind==="market"?" · Market":""}`,i.jsx(de,{size:16,"aria-hidden":"true",className:"shrink-0 text-secondary"})]}),i.jsxs("div",{className:"visibility-scope-menu",children:[l||g?i.jsxs("div",{className:"mb-2 border-b border-default pb-2",children:[i.jsx("button",{type:"button",className:G,"aria-label":`Back to ${F?.label??"all groups"}`,onClick:()=>{k(N.slice(0,-1)),$(!1),b(""),I.current?.focus()},children:i.jsxs("span",{className:"flex items-center gap-1",children:[i.jsx(pe,{size:16,"aria-hidden":"true"}),F?.label??"All groups"]})}),i.jsx("p",{className:"px-2 py-1 text-sm font-medium text-heading","aria-live":"polite",children:l?.label??"All properties"})]}):null,i.jsx("input",{ref:I,type:"search","aria-label":"Search scopes",className:X,placeholder:l?"Search within this group":g?"Search properties":"Search groups or properties",value:f,onChange:t=>b(t.target.value)}),i.jsxs("div",{className:"mt-2 max-h-80 overflow-y-auto",children:[n&&l&&!x?w(l,"All properties in this group"):null,Y.map(t=>w(t)),l&&!x?Q("Subgroups",A,!0):D(l?"Subgroups":"Groups",A),x?D("Properties",V):Q(l&&A.length>0?"All properties":"Properties",V,!l||A.length===0),D("Markets",W),!l&&!g&&!x&&y.length>0&&_.length>0?i.jsxs("button",{type:"button",className:`${G} mt-2 border-t border-default`,"aria-label":q.browseAll,onClick:()=>{$(!0),I.current?.focus()},children:[i.jsx("span",{children:"All properties"}),i.jsx(J,{size:18,"aria-hidden":"true"})]}):null,x&&A.length+V.length+W.length+Y.length===0?i.jsx("p",{className:"py-3 text-sm text-secondary",children:"No matching scopes."}):null]})]})]})]})}function Ee(e){const r=e[0];return r?e.every(o=>o.mode===r.mode&&o.scope.kind===r.scope.kind&&o.scope.key===r.scope.key&&o.queryClass===r.queryClass&&o.measurement.displayedRunId===r.measurement.displayedRunId):!0}function M(e){return e.state==="unavailable"?{numerator:null,denominator:null,reason:e.reason}:e.numerator===void 0||e.denominator===void 0||e.denominator<=0?{numerator:null,denominator:null,reason:"not_applicable"}:{numerator:e.numerator,denominator:e.denominator,...e.unattributed===void 0?{}:{unattributed:e.unattributed},...e.unchecked===void 0?{}:{unchecked:e.unchecked}}}function ye(e){return e.kind==="exact"?e.url:e.kind==="prefix"?`https://${e.host}${e.pathPrefix}/*`:`https://${e.host}/*`}function be(e){return e==="assigned"?"this-property":e==="sibling"?"another-property":e==="ownedUnmapped"?"owned-unassigned":e==="external"?"external":e==="ambiguous"?"multiple-properties":"invalid-url"}function xe(e){return e==="assigned"?"positive":e==="external"?"neutral":e==="invalid"?"negative":"caution"}function te(e){return`target:${e.targetKey}:${e.queryId}:${e.executionNodeKey}`}function ke(e,r,o){const c=new Map;if(!r)return c;const d=new Map(e.usageEdges.map(s=>[te(s),s.targetKey])),p=new Map(e.assignments.map(s=>[`${s.targetKey}:${s.queryId}`,s.queryClass])),n=new Map(e.usageEdges.map(s=>[te(s),p.get(`${s.targetKey}:${s.queryId}`)]));for(const s of r.evidence){if(o&&n.get(s.usageEdgeId)!==o)continue;const f=d.get(s.usageEdgeId);if(!f)continue;const b=c.get(f)??[];b.push({id:`${s.observationId}:${s.expectedSlotId}:${s.usageEdgeId}:${s.sourceUrl}`,kind:be(s.classification),query:s.queryText,provider:s.provider,location:s.location,url:s.sourceUrl,tone:xe(s.classification),historical:s.historical||s.bridged}),c.set(f,b)}return c}function Ce(e){if(e.flags>0)return{label:"Review",tone:"caution"};const r=[e.mentionCoverage,e.citationCoverage].filter(o=>o.state==="unavailable").map(o=>o.reason);return r.includes("no_completed_run")?{label:"Not measured",tone:"neutral"}:r.includes("plan_v1")?{label:"Update setup",tone:"caution"}:r.includes("evidence_incomplete")?{label:"Evidence incomplete",tone:"caution"}:r.includes("identity_ambiguous")?{label:ue.ambiguous,tone:"caution"}:r.includes("no_population")?{label:"No queries",tone:"neutral"}:r.includes("not_applicable")?{label:"Not applicable",tone:"neutral"}:{label:"Complete",tone:"positive"}}function je(e){return e==="complete"?{label:"Complete",tone:"positive"}:e==="partial"?{label:"Partial",tone:"caution"}:e==="queued"?{label:"Queued",tone:"neutral"}:e==="running"?{label:"Running",tone:"neutral"}:e==="failed"?{label:"Failed",tone:"negative"}:{label:"Not measured",tone:"neutral"}}function Ne(e){if(!e)return"";const r=new Date(e);return Number.isFinite(r.getTime())?r.toLocaleDateString("en-US",{month:"short",day:"numeric",year:"numeric",timeZone:"UTC"}):""}function re(e){const r=e.nextAction.count??e.flags.total;if(e.nextAction.kind==="review_flags")return`${r} flagged ${r===1?"result needs":"results need"} review.`;if(e.nextAction.kind==="complete_setup")return"Finish setup.";if(e.nextAction.kind==="republish_setup")return"Setup update required.";if(e.nextAction.kind==="run_measurement")return"Ready to measure."}function qe({overview:e,activePlan:r,report:o,reportState:c=o?"ready":"loading",sort:d}){if(r.plan.schemaVersion!==2||e.mode!=="active-v2")throw new Error("The current overview requires an active version-two setup.");if(e.scope.kind!=="all"&&e.scope.kind!=="group")throw new Error("The current overview requires an All Properties or group scope.");const p=r.plan,n=new Map(p.targets.map(a=>[a.stableKey,a])),s=new Map(p.querySnapshots.map(a=>[a.queryId,a.queryText])),f=new Map;for(const a of p.assignments){if(e.queryClass!=="all"&&a.queryClass!==e.queryClass)continue;const y=s.get(a.queryId);if(!y)continue;const h=f.get(a.targetKey)??new Set;h.add(y),f.set(a.targetKey,h)}const b=o?.revision===r.revision&&o.run?.id===e.measurement.displayedRunId?o:null,N=e.measurement.displayedRunId===void 0||b?"ready":c==="error"||o!=null?"error":"loading",k=ke(p,b,e.queryClass==="all"?void 0:e.queryClass),g=new Map;for(const a of p.groups)for(const y of a.targetKeys)g.has(y)||g.set(y,a.label);const $=e.properties.items.map(a=>{const y=n.get(a.targetKey),h=k.get(a.targetKey)??[];return{id:a.targetKey,name:a.label,mentionCoverage:M(a.mentionCoverage),citationCoverage:M(a.citationCoverage),status:Ce(a),providers:a.providers?.map(l=>({provider:l.provider,mentionCoverage:M(l.mentionCoverage),citationCoverage:M(l.citationCoverage)})),market:g.get(a.targetKey),assignedQueries:[...f.get(a.targetKey)??[]],urls:y?.urlMatchers.map(ye)??[],evidence:h,evidenceState:N,historical:h.some(l=>l.historical)}}),C=e.namedShareOfVoice?.entries.map(a=>({name:a.label,coverage:{numerator:a.credits,denominator:e.namedShareOfVoice.denominator}})),I=e.properties.items.flatMap(a=>a.flags>0?[{id:`property:${a.targetKey}`,property:a.label,summary:`${a.flags} ${a.flags===1?"result needs":"results need"} review.`,tone:"caution",count:a.flags}]:[]);return{classReporting:"available",latestMeasurement:{status:je(e.measurement.state),completedSlots:e.measurement.completed,totalSlots:e.measurement.expected,date:Ne(e.measurement.completedAt),includesBridgedHistory:e.measurement.includesHistoricalData===!0},currentView:{scope:e.scope.kind==="group"?{kind:"group",...e.scope.key?{key:e.scope.key}:{}}:{kind:"all"},queryClass:e.queryClass,aggregate:{metrics:{propertiesMentioned:M(e.metrics.propertiesMentioned),mentionCoverage:M(e.metrics.mentionCoverage),citationCoverage:M(e.metrics.citationCoverage)},properties:$,...C?{shareOfVoice:C}:{}},propertyTotal:e.properties.totalEstimate??$.length,outcomes:e.outcomes,nextCursor:e.properties.nextCursor,...d?{sort:d}:{}},availableGroups:p.groups.map(a=>({id:a.stableKey,label:a.label})),...re(e)?{nextActionText:re(e)}:{},flaggedResultsTotal:e.flags.total,flaggedResults:I}}export{Se as A,q as M,Ke as V,Ae as a,Ee as b,qe as c,ye as m};
package/assets/index.html CHANGED
@@ -12,7 +12,7 @@
12
12
  <link rel="icon" type="image/png" sizes="32x32" href="./favicon-32.png" />
13
13
  <link rel="apple-touch-icon" href="./apple-touch-icon.png" />
14
14
  <title>Canonry</title>
15
- <script type="module" crossorigin src="./assets/index-BaBHBReI.js"></script>
15
+ <script type="module" crossorigin src="./assets/index-DIA9jvMi.js"></script>
16
16
  <link rel="modulepreload" crossorigin href="./assets/vendor-tanstack-ZXXkndVj.js">
17
17
  <link rel="modulepreload" crossorigin href="./assets/vendor-radix-twS1M3FF.js">
18
18
  <link rel="modulepreload" crossorigin href="./assets/vendor-recharts-D-cUuLZo.js">
@@ -86,6 +86,7 @@ import {
86
86
  LOGIN_FAILED_MESSAGE,
87
87
  MEASUREMENT_CHANGES_DEFAULT_SORT,
88
88
  MEASUREMENT_CHANGES_NOISE_ANSWERS,
89
+ MEASUREMENT_DEFAULT_QUERY_CLASS,
89
90
  MEASUREMENT_DRAFT_MAX_ASSIGNMENTS,
90
91
  MEASUREMENT_DRAFT_MAX_ASSIGNMENTS_PER_ACTION,
91
92
  MEASUREMENT_DRAFT_MAX_AUTHORING_BYTES,
@@ -580,6 +581,7 @@ import {
580
581
  measurementPropertyEvidenceResponseSchema,
581
582
  measurementPropertyQuestionsQuerySchema,
582
583
  measurementPropertyQuestionsResponseSchema,
584
+ measurementQueryClassFilterSchema,
583
585
  measurementQuerySetDetailSchema,
584
586
  measurementQuerySetListResponseSchema,
585
587
  measurementQuerySetUpsertRequestSchema,
@@ -846,7 +848,7 @@ import {
846
848
  wordpressSchemaDeployResultDtoSchema,
847
849
  wordpressSchemaStatusResultDtoSchema,
848
850
  wordpressStatusDtoSchema
849
- } from "./chunk-MIRAKDRW.js";
851
+ } from "./chunk-X2S7D3MN.js";
850
852
 
851
853
  // src/intelligence-service.ts
852
854
  import { eq as eq89, desc as desc41, asc as asc18, and as and75, ne as ne16, or as or22, inArray as inArray36, gte as gte24, lte as lte20, isNull as isNull17, sql as sql32, exists as exists2 } from "drizzle-orm";
@@ -16160,7 +16162,15 @@ function identityAmbiguityPatterns(aliases) {
16160
16162
  multipleEntities: patterns.flatMap((pattern) => pattern.multipleEntities)
16161
16163
  };
16162
16164
  }
16163
- function resolveMentionIdentity(text2, targets, aliases, citedTargetIds, ambiguityPatterns = new Map(targets.map((target) => [target.id, identityAmbiguityPatterns(target.aliases)]))) {
16165
+ var NO_TARGETS = /* @__PURE__ */ new Set();
16166
+ function queryNamedTargetIds(queryText, brandedTargetIds, aliases) {
16167
+ if (!queryText || brandedTargetIds === void 0) return NO_TARGETS;
16168
+ const branded = new Set(brandedTargetIds);
16169
+ if (branded.size === 0) return NO_TARGETS;
16170
+ const named = [...mentionedTargetsForAliases(queryText, aliases).mentioned].filter((id) => branded.has(id));
16171
+ return named.length === 0 ? NO_TARGETS : new Set(named);
16172
+ }
16173
+ function resolveMentionIdentity(text2, targets, aliases, citedTargetIds, ambiguityPatterns = new Map(targets.map((target) => [target.id, identityAmbiguityPatterns(target.aliases)])), queryNamed = NO_TARGETS) {
16164
16174
  const textWords = text2 === null ? [] : words(text2);
16165
16175
  const state = mentionedTargetsForAliases(text2, aliases, textWords);
16166
16176
  if (text2 === null) return state;
@@ -16168,8 +16178,10 @@ function resolveMentionIdentity(text2, targets, aliases, citedTargetIds, ambigui
16168
16178
  for (const target of targets) {
16169
16179
  if (!state.mentioned.has(target.id)) continue;
16170
16180
  const patterns = ambiguityPatterns.get(target.id);
16171
- const qualified = citedTargetIds.has(target.id) || (target.identityAliases?.length ?? 0) > 0 && containsAnyAlias(text2, target.identityAliases);
16172
- const unresolved = patterns?.clarification.some((pattern) => pattern.test(normalized)) || !qualified && (patterns?.multipleEntities.some((pattern) => pattern.test(normalized)) || (target.identityAliases?.length ?? 0) > 0);
16181
+ const cited = citedTargetIds.has(target.id);
16182
+ const qualified = cited || (target.identityAliases?.length ?? 0) > 0 && containsAnyAlias(text2, target.identityAliases);
16183
+ const clarified = cited || queryNamed.has(target.id);
16184
+ const unresolved = !clarified && patterns?.clarification.some((pattern) => pattern.test(normalized)) || !qualified && (patterns?.multipleEntities.some((pattern) => pattern.test(normalized)) || (target.identityAliases?.length ?? 0) > 0);
16173
16185
  if (unresolved) {
16174
16186
  state.mentioned.delete(target.id);
16175
16187
  state.unknown.add(target.id);
@@ -16184,13 +16196,14 @@ function createTargetMentionReader(targets, ownedHosts = []) {
16184
16196
  const ambiguityPatterns = new Map(targets.map((target) => [target.id, identityAmbiguityPatterns(target.aliases)]));
16185
16197
  const routes = compiledTargetRoutes(targets);
16186
16198
  const normalizedOwnedHosts = ownedHosts.map(normalizedHost);
16187
- return (answerText, targetIds, citedUrls = []) => {
16199
+ return (answerText, targetIds, citedUrls = [], query = null) => {
16188
16200
  if (answerText === null || targetIds.length === 0) return null;
16189
16201
  const citedTargetIds = new Set(citedUrls.flatMap((url) => {
16190
16202
  const source = classifySourceAttribution(url, routes, normalizedOwnedHosts);
16191
16203
  return source.classification === "matched" ? source.matchedTargetIds : [];
16192
16204
  }));
16193
- const state = resolveMentionIdentity(answerProseForMentions(answerText), targets, aliases, citedTargetIds, ambiguityPatterns);
16205
+ const queryNamed = query === null ? NO_TARGETS : queryNamedTargetIds(query.text, query.brandedTargetIds.filter((id) => targetIds.includes(id)), aliases);
16206
+ const state = resolveMentionIdentity(answerProseForMentions(answerText), targets, aliases, citedTargetIds, ambiguityPatterns, queryNamed);
16194
16207
  if (targetIds.some((id) => state.mentioned.has(id))) return true;
16195
16208
  return targetIds.some((id) => !mentionableIds.has(id) || state.unknown.has(id)) ? null : false;
16196
16209
  };
@@ -16293,12 +16306,28 @@ function prepareReport(input, options = {}, detailedEvidence = true) {
16293
16306
  const mentionableIds = new Set(
16294
16307
  mentionAliases.map((alias2) => alias2.targetId)
16295
16308
  );
16309
+ const queryNamedByExecution = /* @__PURE__ */ new Map();
16310
+ const queryNamedFor = (slot) => {
16311
+ const cached = queryNamedByExecution.get(slot.executionId);
16312
+ if (cached !== void 0) return cached;
16313
+ const branded = (edgesByExecution.get(slot.executionId) ?? []).flatMap((edge) => edge.type === "target" && edge.queryClass === "branded" ? [edge.targetId] : []);
16314
+ const named = queryNamedTargetIds(slot.queryText, branded, aliasesByFirstWord);
16315
+ queryNamedByExecution.set(slot.executionId, named);
16316
+ return named;
16317
+ };
16296
16318
  for (const observation of observationsBySlot.values()) {
16297
16319
  const citedTargetIds = new Set(observation.sourceUrls.flatMap((url) => {
16298
16320
  const source = sourceAttribution(url);
16299
16321
  return source.classification === "matched" ? source.matchedTargetIds : [];
16300
16322
  }));
16301
- const mentions = resolveMentionIdentity(observation.mentionText, input.targets, aliasesByFirstWord, citedTargetIds, ambiguityPatterns);
16323
+ const mentions = resolveMentionIdentity(
16324
+ observation.mentionText,
16325
+ input.targets,
16326
+ aliasesByFirstWord,
16327
+ citedTargetIds,
16328
+ ambiguityPatterns,
16329
+ queryNamedFor(observation.slot)
16330
+ );
16302
16331
  observation.mentionedTargetIds = mentions.mentioned;
16303
16332
  observation.unknownMentionTargetIds = mentions.unknown;
16304
16333
  observation.citedTargetIds = citedTargetIds;
@@ -17068,9 +17097,10 @@ function buildMeasurementPlanV2ReportInput(revision, plan, manifest, snapshots)
17068
17097
  }
17069
17098
  };
17070
17099
  }
17071
- function responseFromReport(revision, report, run) {
17100
+ function responseFromReport(revision, report, run, queryClass) {
17072
17101
  return {
17073
17102
  revision,
17103
+ queryClass,
17074
17104
  run,
17075
17105
  groups: report.groups,
17076
17106
  targets: report.targets,
@@ -17133,31 +17163,38 @@ function measurementRunExpectedSlots(run, plan) {
17133
17163
  if (run.measurementManifest === null) manifestFailure(`missing for run ${run.id}`);
17134
17164
  return parseManifest(run.measurementManifest, frozenExecutionNodes(plan), run.measurementScope === null);
17135
17165
  }
17136
- function storedMeasurementPlanV2Report(db, projectId, version, plan, runId) {
17166
+ function storedMeasurementPlanV2Report(db, projectId, version, plan, runId, queryClass) {
17137
17167
  const run = runId ? pinnedMeasurementRun(db, projectId, version.id, runId, { exactVersion: true }) : latestMeasurementRun(db, projectId, version.id, [RunStatuses.completed, RunStatuses.partial], {}, { exactVersion: true });
17138
17168
  if (!run) {
17139
17169
  const empty = buildMeasurementPlanV2ReportInput(version.revision, plan, { schemaVersion: 1, expectedSlots: [] }, []);
17140
17170
  return {
17141
17171
  kind: "no-population",
17142
17172
  reason: "no-run",
17143
- report: responseFromReport(version.revision, buildMeasurementReport(empty.input), null)
17173
+ report: responseFromReport(version.revision, buildMeasurementReport(classInput(empty, queryClass)), null, queryClass)
17144
17174
  };
17145
17175
  }
17146
17176
  const manifest = measurementRunExpectedSlots(run, plan);
17147
17177
  const snapshots = db.select().from(querySnapshots).where(eq15(querySnapshots.runId, run.id)).all();
17148
- const { input } = buildMeasurementPlanV2ReportInput(version.revision, plan, manifest, snapshots);
17178
+ const materialized = buildMeasurementPlanV2ReportInput(version.revision, plan, manifest, snapshots);
17149
17179
  return {
17150
17180
  kind: "report",
17151
- report: responseFromReport(version.revision, buildMeasurementReport(input), {
17181
+ report: responseFromReport(version.revision, buildMeasurementReport(classInput(materialized, queryClass)), {
17152
17182
  id: run.id,
17153
17183
  status: run.status === RunStatuses.completed ? RunStatuses.completed : RunStatuses.partial,
17154
17184
  createdAt: run.createdAt,
17155
17185
  startedAt: run.startedAt,
17156
17186
  finishedAt: run.finishedAt
17157
- })
17187
+ }, queryClass)
17158
17188
  };
17159
17189
  }
17160
- function buildStoredMeasurementReport(db, projectId, revision, runId) {
17190
+ function classInput(materialized, queryClass) {
17191
+ if (queryClass === "all") return materialized.input;
17192
+ return {
17193
+ ...materialized.input,
17194
+ usageEdges: materialized.input.usageEdges.filter((edge) => materialized.edgeQueryClass.get(edge.id) === queryClass)
17195
+ };
17196
+ }
17197
+ function buildStoredMeasurementReport(db, projectId, revision, runId, queryClass) {
17161
17198
  const version = db.select().from(measurementPlanVersions).where(and9(
17162
17199
  eq15(measurementPlanVersions.projectId, projectId),
17163
17200
  eq15(measurementPlanVersions.revision, revision)
@@ -17165,7 +17202,12 @@ function buildStoredMeasurementReport(db, projectId, revision, runId) {
17165
17202
  if (!version) return { kind: "no-plan", revision };
17166
17203
  const stored = parseStoredMeasurementPlanAnyVersion(version.canonicalJson);
17167
17204
  if (stored.schemaVersion === MEASUREMENT_PLAN_V2_SCHEMA_VERSION) {
17168
- return storedMeasurementPlanV2Report(db, projectId, version, stored, runId);
17205
+ return storedMeasurementPlanV2Report(db, projectId, version, stored, runId, queryClass ?? MEASUREMENT_DEFAULT_QUERY_CLASS);
17206
+ }
17207
+ if (queryClass !== void 0 && queryClass !== "all") {
17208
+ throw validationError(
17209
+ `Revision ${revision} is a schema v1 plan, which records no query class. Omit queryClass to read every answer.`
17210
+ );
17169
17211
  }
17170
17212
  const plan = stored;
17171
17213
  const run = runId ? pinnedMeasurementRun(db, projectId, version.id, runId, { exactVersion: true }) : db.select().from(runs).where(and9(
@@ -17192,7 +17234,7 @@ function buildStoredMeasurementReport(db, projectId, revision, runId) {
17192
17234
  )).orderBy(desc5(runs.createdAt), desc5(runs.id)).get();
17193
17235
  if (!selectedRun) {
17194
17236
  const report2 = buildMeasurementReport(reportInput(version.revision, plan, { schemaVersion: 1, expectedSlots: [] }, [], false));
17195
- return { kind: "no-population", reason: "no-run", report: responseFromReport(version.revision, report2, null) };
17237
+ return { kind: "no-population", reason: "no-run", report: responseFromReport(version.revision, report2, null, null) };
17196
17238
  }
17197
17239
  const legacySnapshots = db.select().from(querySnapshots).where(eq15(querySnapshots.runId, selectedRun.id)).all();
17198
17240
  const providers = [...new Set(legacySnapshots.map((snapshot) => snapshot.provider.trim().toLocaleLowerCase("en")).filter(Boolean))];
@@ -17200,12 +17242,12 @@ function buildStoredMeasurementReport(db, projectId, revision, runId) {
17200
17242
  manifest = buildMeasurementRunManifest(plan, providers);
17201
17243
  } catch {
17202
17244
  const report2 = buildMeasurementReport(reportInput(version.revision, plan, { schemaVersion: 1, expectedSlots: [] }, [], false));
17203
- return { kind: "no-population", reason: "no-run", report: responseFromReport(version.revision, report2, null) };
17245
+ return { kind: "no-population", reason: "no-run", report: responseFromReport(version.revision, report2, null, null) };
17204
17246
  }
17205
17247
  legacy = true;
17206
17248
  } else {
17207
17249
  const report2 = buildMeasurementReport(reportInput(version.revision, plan, { schemaVersion: 1, expectedSlots: [] }, [], false));
17208
- return { kind: "no-population", reason: "no-run", report: responseFromReport(version.revision, report2, null) };
17250
+ return { kind: "no-population", reason: "no-run", report: responseFromReport(version.revision, report2, null, null) };
17209
17251
  }
17210
17252
  const snapshots = db.select().from(querySnapshots).where(eq15(querySnapshots.runId, selectedRun.id)).all();
17211
17253
  const report = buildMeasurementReport(reportInput(version.revision, plan, manifest, snapshots, legacy));
@@ -17217,7 +17259,7 @@ function buildStoredMeasurementReport(db, projectId, revision, runId) {
17217
17259
  createdAt: selectedRun.createdAt,
17218
17260
  startedAt: selectedRun.startedAt,
17219
17261
  finishedAt: selectedRun.finishedAt
17220
- })
17262
+ }, null)
17221
17263
  };
17222
17264
  }
17223
17265
 
@@ -19701,6 +19743,9 @@ var CURRENT_RUN_STATUSES = [
19701
19743
  RunStatuses.partial,
19702
19744
  RunStatuses.failed
19703
19745
  ];
19746
+ function servedQueryClass(query) {
19747
+ return query.queryClass ?? MEASUREMENT_DEFAULT_QUERY_CLASS;
19748
+ }
19704
19749
  var MEASUREMENT_OVERVIEW_CACHE_MAX_ENTRIES = 32;
19705
19750
  function cacheKeyOf(key) {
19706
19751
  return JSON.stringify([
@@ -19743,6 +19788,9 @@ function parseOverviewQuery(raw) {
19743
19788
  };
19744
19789
  const parsed = measurementOverviewQuerySchema.safeParse(candidate);
19745
19790
  if (!parsed.success) throw validationError("Invalid measurement overview query", { issues: parsed.error.issues });
19791
+ if (parsed.data.marketKey !== void 0 && parsed.data.scope !== "market") {
19792
+ throw validationError(`"marketKey" is accepted only when scope is "market"; scope "${parsed.data.scope}" does not narrow to a market.`);
19793
+ }
19746
19794
  return parsed.data;
19747
19795
  }
19748
19796
  function activeMeasurementPlan(db, projectId) {
@@ -19801,8 +19849,9 @@ function overviewFilterFingerprint(query) {
19801
19849
  const filters = {
19802
19850
  scope: query.scope,
19803
19851
  groupKey: query.groupKey ?? null,
19852
+ marketKey: query.marketKey ?? null,
19804
19853
  targetKey: query.targetKey ?? null,
19805
- queryClass: query.queryClass ?? "all",
19854
+ queryClass: servedQueryClass(query),
19806
19855
  provider: query.provider === void 0 ? null : normalizeIdentityText(query.provider),
19807
19856
  location: query.location === void 0 ? null : normalizeIdentityText(query.location),
19808
19857
  from: query.from ?? null,
@@ -19816,8 +19865,9 @@ function overviewAggregateFingerprint(query) {
19816
19865
  const filters = {
19817
19866
  scope: query.scope,
19818
19867
  groupKey: query.groupKey ?? null,
19868
+ marketKey: query.marketKey ?? null,
19819
19869
  targetKey: query.targetKey ?? null,
19820
- queryClass: query.queryClass ?? "all",
19870
+ queryClass: servedQueryClass(query),
19821
19871
  provider: query.provider === void 0 ? null : normalizeIdentityText(query.provider),
19822
19872
  location: query.location === void 0 ? null : normalizeIdentityText(query.location),
19823
19873
  from: query.from ?? null,
@@ -20061,6 +20111,7 @@ function resolveScope(plan, query) {
20061
20111
  group: v2GroupOf(plan, groupKey)
20062
20112
  };
20063
20113
  }
20114
+ if (query.scope === "market") return resolveMarketScope(plan, query.marketKey);
20064
20115
  if (query.scope === "property") {
20065
20116
  if (query.targetKey === void 0) throw validationError('"targetKey" is required when scope is "property".');
20066
20117
  const target = plan.targets.find((candidate) => candidate.stableKey === query.targetKey);
@@ -20069,6 +20120,24 @@ function resolveScope(plan, query) {
20069
20120
  }
20070
20121
  return { kind: "all", label: "All Properties", targetKeys: plan.targets.map((target) => target.stableKey), group: null };
20071
20122
  }
20123
+ function resolveMarketScope(plan, marketKey) {
20124
+ if (marketKey === void 0) throw validationError('"marketKey" is required when scope is "market".');
20125
+ const notInRevision = () => validationError(`Measurement market "${marketKey}" is not in the active revision.`);
20126
+ if (plan.schemaVersion !== MEASUREMENT_PLAN_V2_SCHEMA_VERSION) throw notInRevision();
20127
+ const market = plan.reportingScopes?.find((candidate) => candidate.stableKey === marketKey);
20128
+ if (!market) throw notInRevision();
20129
+ const members = new Set(market.usageEdges.map(measurementV2UsageEdgeKey));
20130
+ const edges = plan.usageEdges.filter((edge) => members.has(measurementV2UsageEdgeKey(edge)));
20131
+ const targetKeys = new Set(edges.map((edge) => edge.targetKey));
20132
+ return {
20133
+ kind: "market",
20134
+ key: market.stableKey,
20135
+ label: market.label,
20136
+ targetKeys: plan.targets.map((target) => target.stableKey).filter((targetKey) => targetKeys.has(targetKey)),
20137
+ group: null,
20138
+ edgeIds: new Set(edges.map(v2UsageEdgeId))
20139
+ };
20140
+ }
20072
20141
  function namedIdentitiesFor(plan, scope, queryClass) {
20073
20142
  if (scope.kind !== "group" || queryClass !== "non-brand" || scope.group === null) return [];
20074
20143
  if (scope.group.competitors.length === 0) return [];
@@ -20186,7 +20255,7 @@ function planV1Overview(db, projectId, active, query, scope) {
20186
20255
  return {
20187
20256
  mode: "active-v1",
20188
20257
  scope: scopeDto(scope),
20189
- queryClass: query.queryClass ?? "all",
20258
+ queryClass: servedQueryClass(query),
20190
20259
  measurement: {
20191
20260
  state: displayed ? displayedState(displayed.status) : "not_measured",
20192
20261
  ...displayed ? { currentRunId: displayed.id, displayedRunId: displayed.id } : {},
@@ -20207,7 +20276,7 @@ function planV1Overview(db, projectId, active, query, scope) {
20207
20276
  };
20208
20277
  }
20209
20278
  function planV2Overview(db, projectId, active, plan, query, scope, cache) {
20210
- const queryClass = query.queryClass ?? "all";
20279
+ const queryClass = servedQueryClass(query);
20211
20280
  const displayed = selectDisplayedRun(db, projectId, active, query);
20212
20281
  const current = latestMeasurementRun(db, projectId, active.version.id, CURRENT_RUN_STATUSES);
20213
20282
  const currentDto = current ? { currentRunId: current.id } : {};
@@ -20263,7 +20332,7 @@ function planV2Overview(db, projectId, active, plan, query, scope, cache) {
20263
20332
  const manifest = measurementRunExpectedSlots(displayed, plan);
20264
20333
  const { input, edgeQueryClass } = buildMeasurementPlanV2ReportInput(active.version.revision, plan, manifest, snapshots);
20265
20334
  const expectedSlots = input.expectedSlots.filter((slot) => (query.provider === void 0 || slot.provider === normalizeIdentityText(query.provider)) && (query.location === void 0 || normalizeIdentityText(slot.location ?? "") === normalizeIdentityText(query.location)));
20266
- const usageEdges = queryClass === "all" ? input.usageEdges : input.usageEdges.filter((edge) => edgeQueryClass.get(edge.id) === queryClass);
20335
+ const usageEdges = input.usageEdges.filter((edge) => (queryClass === "all" || edgeQueryClass.get(edge.id) === queryClass) && (scope.edgeIds === void 0 || scope.edgeIds.has(edge.id)));
20267
20336
  return buildMeasurementOverview({
20268
20337
  ...input,
20269
20338
  expectedSlots,
@@ -20810,12 +20879,23 @@ function scopeForFrozenPlan(plan, kind, groupKey) {
20810
20879
  ids.add(edge.targetKey);
20811
20880
  targetIdsByExecution.set(edge.executionNodeKey, ids);
20812
20881
  }
20882
+ const queryTextByExecution = new Map(plan.executionNodes.map((node) => [node.stableKey, node.queryText]));
20883
+ const brandedTargetIdsByExecution = /* @__PURE__ */ new Map();
20884
+ for (const assignment of plan.assignments) {
20885
+ if (assignment.queryClass !== "branded") continue;
20886
+ const ids = brandedTargetIdsByExecution.get(assignment.executionNodeKey) ?? [];
20887
+ ids.push(assignment.targetKey);
20888
+ brandedTargetIdsByExecution.set(assignment.executionNodeKey, ids);
20889
+ }
20813
20890
  return {
20814
20891
  executionNodeKeys,
20815
20892
  queryClassesByExecution,
20816
20893
  mentioned: (answerText, executionId, citedUrls) => {
20817
20894
  const ids = executionId === null ? [] : [...targetIdsByExecution.get(executionId) ?? []];
20818
- return readMention(answerText, ids, citedUrls);
20895
+ const queryText = executionId === null ? void 0 : queryTextByExecution.get(executionId);
20896
+ const brandedTargetIds = executionId === null ? void 0 : brandedTargetIdsByExecution.get(executionId);
20897
+ const query = queryText === void 0 || brandedTargetIds === void 0 ? null : { text: queryText, brandedTargetIds };
20898
+ return readMention(answerText, ids, citedUrls, query);
20819
20899
  },
20820
20900
  competitors: mergePins(groups.flatMap((group) => group.competitors.map((competitor) => ({
20821
20901
  domain: competitor.domain,
@@ -23011,7 +23091,13 @@ async function measurementServiceRoutes(app, opts) {
23011
23091
  if (runId !== void 0 && (typeof runId !== "string" || runId.trim() === "")) {
23012
23092
  throw validationError('"runId" must be a non-empty string');
23013
23093
  }
23014
- const result = buildStoredMeasurementReport(app.db, project.id, revision, runId);
23094
+ let queryClass;
23095
+ if (request.query.queryClass !== void 0) {
23096
+ const parsedClass = measurementQueryClassFilterSchema.safeParse(request.query.queryClass);
23097
+ if (!parsedClass.success) throw validationError('"queryClass" must be one of non-brand, branded or all');
23098
+ queryClass = parsedClass.data;
23099
+ }
23100
+ const result = buildStoredMeasurementReport(app.db, project.id, revision, runId, queryClass);
23015
23101
  if (result.kind === "no-plan") throw notFound("Measurement plan revision", rawRevision);
23016
23102
  if (runId !== void 0 && result.report.run?.id !== runId) throw notFound("Measurement run", runId);
23017
23103
  return measurementReportResponseSchema.parse(result.report);
@@ -23059,12 +23145,17 @@ function parseDraftMatcher(value) {
23059
23145
  function matcherHost(matcher) {
23060
23146
  return matcher.kind === "exact" ? new URL(matcher.url).hostname : matcher.host;
23061
23147
  }
23148
+ function matcherPathIdentity(path8, pathCase) {
23149
+ return pathCase === "insensitive" ? path8.toLocaleLowerCase("en") : path8;
23150
+ }
23062
23151
  function matcherIdentity(matcher) {
23063
23152
  switch (matcher.kind) {
23064
- case "exact":
23065
- return `exact\0${new URL(matcher.url).hostname}\0${new URL(matcher.url).pathname}`;
23153
+ case "exact": {
23154
+ const url = new URL(matcher.url);
23155
+ return `exact\0${url.hostname}\0${matcherPathIdentity(url.pathname, matcher.pathCase)}`;
23156
+ }
23066
23157
  case "prefix":
23067
- return `prefix\0${matcher.host}\0${matcher.pathPrefix}`;
23158
+ return `prefix\0${matcher.host}\0${matcherPathIdentity(matcher.pathPrefix, matcher.pathCase)}`;
23068
23159
  case "host":
23069
23160
  return `host\0${matcher.host}\0`;
23070
23161
  }
@@ -38769,6 +38860,13 @@ var measurementReportRunParameter = {
38769
38860
  description: "Eligible full measurement run to reconstruct. Omit to use the latest run for the revision.",
38770
38861
  schema: stringSchema
38771
38862
  };
38863
+ var measurementReportQueryClassParameter = {
38864
+ name: "queryClass",
38865
+ in: "query",
38866
+ required: false,
38867
+ description: "Query class every group, Target and evidence row is taken over. Defaults to non-brand; branded is a separate read. all pools branded and non-brand into one rate and is served only when asked for. A schema v1 revision records no class: omit this (or pass all) to read every answer, and the response echoes queryClass null.",
38868
+ schema: { type: "string", enum: ["non-brand", "branded", "all"], default: "non-brand" }
38869
+ };
38772
38870
  var runIdParameter = {
38773
38871
  name: "id",
38774
38872
  in: "path",
@@ -39482,12 +39580,12 @@ var routeCatalog = [
39482
39580
  method: "get",
39483
39581
  path: "/api/v1/projects/{name}/measurement-report",
39484
39582
  summary: "Get a revision-pinned measurement report",
39485
- description: "Builds the Target, group, and evidence report from the immutable plan revision and either its latest eligible stored run or the exact eligible runId supplied by the caller. Missing run population remains explicit and never triggers live provider execution.",
39583
+ description: "Builds the Target, group, and evidence report from the immutable plan revision and either its latest eligible stored run or the exact eligible runId supplied by the caller. On a schema v2 revision every rate is taken over one query class, non-brand unless queryClass names another; the response echoes the class it served. Missing run population remains explicit and never triggers live provider execution.",
39486
39584
  tags: ["measurement-plans"],
39487
- parameters: [nameParameter, measurementReportRevisionParameter, measurementReportRunParameter],
39585
+ parameters: [nameParameter, measurementReportRevisionParameter, measurementReportRunParameter, measurementReportQueryClassParameter],
39488
39586
  responses: {
39489
39587
  200: jsonResponse("Revision-pinned measurement report returned.", "MeasurementReportResponse"),
39490
- 400: errorResponse("The revision query parameter is invalid."),
39588
+ 400: errorResponse("The revision or queryClass parameter is invalid, or a class was requested for a schema v1 revision."),
39491
39589
  404: errorResponse("Project, measurement-plan revision, or requested run not found.")
39492
39590
  }
39493
39591
  },
@@ -39754,15 +39852,16 @@ var routeCatalog = [
39754
39852
  method: "get",
39755
39853
  path: "/api/v1/projects/{name}/measurement-overview",
39756
39854
  summary: "Get the scoped measurement overview",
39757
- description: "Aggregates one revision-pinned run snapshot for All Properties, a group, or a single Property. This is snapshot ranking only: it never infers a trend or compares evidence across revisions. Without runId the most recent completed run pinned to the active revision is used; once paging begins, the cursor pins that revision, displayed run, evidence snapshot, and result filters. A run pinned to another revision is refused rather than joined, and appended evidence on a mutable named run invalidates its cursor. On a schema v2 plan every Property row carries its metro (the top-level group holding it, or null) and, when it sits in several top-level groups, otherMetros. Metrics are computed before search is applied, and a metric with no evidence is unavailable rather than zero. For coverage sorts, unavailable rows form the first bucket in either direction before available numeric rates follow the requested direction.",
39855
+ description: "Aggregates one revision-pinned run snapshot for All Properties, a group, a market, or a single Property. A group reads every query its Properties are assigned; a market reads only its own frozen queries, the population the dashboard's market view reads, and the response scope names which kind was read. Rates are taken over one query class, non-brand unless queryClass names another; all pools branded with non-brand and is served only when asked for. This is snapshot ranking only: it never infers a trend or compares evidence across revisions. Without runId the most recent completed run pinned to the active revision is used; once paging begins, the cursor pins that revision, displayed run, evidence snapshot, and result filters. A run pinned to another revision is refused rather than joined, and appended evidence on a mutable named run invalidates its cursor. On a schema v2 plan every Property row carries its metro (the top-level group holding it, or null) and, when it sits in several top-level groups, otherMetros. Metrics are computed before search is applied, and a metric with no evidence is unavailable rather than zero. For coverage sorts, unavailable rows form the first bucket in either direction before available numeric rates follow the requested direction.",
39758
39856
  tags: ["measurement-plans"],
39759
39857
  parameters: [
39760
39858
  nameParameter,
39761
39859
  { name: "compact", in: "query", description: "Byte-bounded whole-row page; omits optional heavy detail with explicit metadata. Default false for compatibility.", schema: { type: "boolean" } },
39762
- { name: "scope", in: "query", required: true, description: "Reporting scope.", schema: { type: "string", enum: ["all", "group", "property"] } },
39860
+ { name: "scope", in: "query", required: true, description: "Reporting scope. group is every query of the group's Properties; market is only the market's own queries.", schema: { type: "string", enum: ["all", "group", "market", "property"] } },
39763
39861
  { name: "groupKey", in: "query", description: 'Group stable key, required when scope is "group".', schema: stringSchema },
39862
+ { name: "marketKey", in: "query", description: 'Market stable key (a frozen reporting scope), required when scope is "market" and refused (400) with any other scope.', schema: stringSchema },
39764
39863
  { name: "targetKey", in: "query", description: 'Target stable key, required when scope is "property".', schema: stringSchema },
39765
- { name: "queryClass", in: "query", description: "Restrict to one question class. Never pooled across classes.", schema: { type: "string", enum: ["all", "branded", "non-brand"] } },
39864
+ { name: "queryClass", in: "query", description: "Query class the rates are taken over. Defaults to non-brand; read branded as a separate request. all pools branded and non-brand into one rate.", schema: { type: "string", enum: ["non-brand", "branded", "all"], default: "non-brand" } },
39766
39865
  { name: "provider", in: "query", description: "Restrict to one answer provider.", schema: stringSchema },
39767
39866
  { name: "location", in: "query", description: "Restrict to one execution location label.", schema: stringSchema },
39768
39867
  { name: "from", in: "query", description: "Inclusive start of the window (YYYY-MM-DD).", schema: stringSchema },
@@ -40010,14 +40109,14 @@ var routeCatalog = [
40010
40109
  method: "get",
40011
40110
  path: "/api/v1/projects/{name}/measurement-changes",
40012
40111
  summary: "Compare the latest two comparable measurements",
40013
- description: "Compares stored runs only when plan revision, execution identity, and full-or-spot-check scope agree. Deltas are current minus previous; it never crosses a revision or silently joins an engine/model change. changedProperties is ordered by the size of each move unless sort=label, and each row carries signed answer-count deltas, denominatorChanged (a metric was taken over a different number of answers, so its delta is not like for like) and withinNoise (every move is at most 2 answers). A move is the rate change times the larger of the two answer counts, the answer-count delta whenever the denominator held, so a falling rate never reads as a gain and a collapse never reads as noise. distribution buckets every Property in scope, not just the returned rows. With queryClass all, metricsByClass reports branded and non-brand beside the pooled metrics.",
40112
+ description: "Compares stored runs only when plan revision, execution identity, and full-or-spot-check scope agree. Deltas are current minus previous; it never crosses a revision or silently joins an engine/model change. changedProperties is ordered by the size of each move unless sort=label, and each row carries signed answer-count deltas, denominatorChanged (a metric was taken over a different number of answers, so its delta is not like for like) and withinNoise (every move is at most 2 answers). A move is the rate change times the larger of the two answer counts, the answer-count delta whenever the denominator held, so a falling rate never reads as a gain and a collapse never reads as noise. distribution buckets every Property in scope, not just the returned rows. Rates are taken over non-brand queries unless queryClass names another class. With queryClass all, the metrics, rows and distribution pool branded with non-brand, and metricsByClass reports each class beside them.",
40014
40113
  tags: ["measurement-plans"],
40015
40114
  parameters: [
40016
40115
  nameParameter,
40017
40116
  { name: "scope", in: "query", description: "Reporting scope. Defaults to all.", schema: { type: "string", enum: ["all", "group", "property"], default: "all" } },
40018
40117
  { name: "groupKey", in: "query", description: "Required for group scope.", schema: stringSchema },
40019
40118
  { name: "targetKey", in: "query", description: "Required for Property scope.", schema: stringSchema },
40020
- { name: "queryClass", in: "query", description: "Question class. Defaults to all.", schema: { type: "string", enum: ["all", "branded", "non-brand"], default: "all" } },
40119
+ { name: "queryClass", in: "query", description: "Query class. Defaults to non-brand; read branded as a separate request. all pools both classes.", schema: { type: "string", enum: ["non-brand", "branded", "all"], default: "non-brand" } },
40021
40120
  { name: "provider", in: "query", description: "Restrict both runs to one answer provider.", schema: stringSchema },
40022
40121
  { name: "location", in: "query", description: "Restrict both runs to one execution location label.", schema: stringSchema },
40023
40122
  { name: "runId", in: "query", description: "Use this completed or partial run as the current side.", schema: stringSchema },